From c1fa1c77fc32a84929c9948576dadeba67381333 Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Thu, 17 Sep 2020 07:59:03 -0500 Subject: [PATCH] Re-organized CLI args. TODO: Validate mHash input, finish `peer block`. --- README.md | 2 +- build.sh | 2 +- project/cli.go | 69 +++++++++++++++++++++++++++----------------------- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 4e9096c..3b9ec89 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ You can override this value by specifying a `PIGEON_PATH` ENV var. - [ ] Get a good CI system going? Run tests at PR time, provide prebuilt binaries, prevent coverage slips, etc.. - [ ] Finish all the things below: - |Done?|Verb |Noun | Flag / arg 1 | Flag 2 | + |Done?|Noun |Verb | Flag / arg 1 | Flag 2 | |-----|------------|-----------|---------------|-----------| | |peer |block | peer mhash | | | |peer |follow | peer mhash | | diff --git a/build.sh b/build.sh index 1100aaf..484f548 100755 --- a/build.sh +++ b/build.sh @@ -5,4 +5,4 @@ go build --o=../pigeon-cli cd - PIGEON_PATH="." ./pigeon-cli version -./pigeon-cli show identity +./pigeon-cli identity show diff --git a/project/cli.go b/project/cli.go index faec561..099c93a 100644 --- a/project/cli.go +++ b/project/cli.go @@ -27,30 +27,17 @@ var versionCmd = &cobra.Command{ }, } -// CLI: `pigeon show [resource]` -var showCmd = &cobra.Command{ - Use: "show [resource]", - Short: "Show various resources", - Long: `Shows resources such as blobs, drafts, identities, messages, peers, etc..`, -} - -// CLI: `pigeon follow [resource]` -var followCmd = &cobra.Command{ - Use: "follow [resource]", - Short: "follow various resources", - Long: `Follows resources such as blobs, drafts, identities, messages, peers, etc..`, -} - -// CLI: `pigeon create [resource]` -var createCmd = &cobra.Command{ - Use: "create [resource]", - Short: "Create various resources", - Long: `Creates resources, such as identities, drafts, messages, blobs, etc..`, -} - -// CLI: `pigeon create identity` -var createIdentityCmd = &cobra.Command{ +// CLI: `pigeon identity` +var identityRootCmd = &cobra.Command{ Use: "identity", + Short: "Identity related commands", + Run: func(cmd *cobra.Command, args []string) { + }, +} + +// CLI: `pigeon identity create` +var identityCreateCmd = &cobra.Command{ + Use: "create", Short: "Create a new identity.", Long: `Creates a new identity.`, Run: func(cmd *cobra.Command, args []string) { @@ -58,8 +45,8 @@ var createIdentityCmd = &cobra.Command{ }, } -// CLI: `pigeon show identity` -var showIdentityCmd = &cobra.Command{ +// CLI: `pigeon identity show` +var identityShowCmd = &cobra.Command{ Use: "identity", Short: "Show current user identity.", Long: `Prints the current Pigeon identity to screen. Prints 'NONE' if @@ -69,15 +56,35 @@ var showIdentityCmd = &cobra.Command{ }, } +// CLI: `pigeon peer` +var peerRootCmd = &cobra.Command{ + Use: "peer(s)", + Short: "Peer related commands", + Aliases: []string{"peer", "peers"}, + Run: func(cmd *cobra.Command, args []string) { + }, +} + +var peerBlockCmd = &cobra.Command{ + Use: "block", + Short: "Block a peer from your local node.", + Run: func(cmd *cobra.Command, args []string) { + mhash := args[0] + fmt.Printf("TODO: Validate this input string %s\n", mhash) + }, +} + // BootstrapCLI wires up all the relevant commands. func BootstrapCLI() { - createCmd.AddCommand(createIdentityCmd) - showCmd.AddCommand(showIdentityCmd) - followCmd.AddCommand() - rootCmd.AddCommand(createCmd) - rootCmd.AddCommand(followCmd) - rootCmd.AddCommand(showCmd) rootCmd.AddCommand(versionCmd) + + rootCmd.AddCommand(identityRootCmd) + identityRootCmd.AddCommand(identityShowCmd) + identityRootCmd.AddCommand(identityCreateCmd) + + rootCmd.AddCommand(peerRootCmd) + peerRootCmd.AddCommand(peerBlockCmd) + if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1)