diff --git a/README.md b/README.md index 77e40f1..6a5870f 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ go test -v ./... With coverage: ``` -go test -v ./... -coverprofile coverage.out +go test -coverprofile coverage.out go tool cover -html=coverage.out ``` diff --git a/cli.go b/cli.go new file mode 100644 index 0000000..1ec25f9 --- /dev/null +++ b/cli.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "os" + + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "pigeon", + Short: "Pigeon is a peer-to-peer database for offline systems", + Long: `Pigeon is an off-grid, serverless, peer-to-peer + database for building software that works on poor internet + connections, or entirely offline.`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("It works!") + }, +} + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "This is the short description of version", + Long: `This one is longer.`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Printf("Pigeon CLI Client (Golang), version %s\n", Version) + }, +} + +// BootstrapCLI wires up all the relevant commands. +func BootstrapCLI() { + rootCmd.AddCommand(versionCmd) + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/main.go b/main.go index da29a2c..41333fb 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,5 @@ package main func main() { + BootstrapCLI() }