github.com/adowair/kvdb@v0.0.0-20231101174258-ceca93b03596/cmd/root.go (about) 1 package cmd 2 3 import ( 4 "os" 5 6 "github.com/spf13/cobra" 7 ) 8 9 // rootCmd represents the base command when called without any subcommands 10 var rootCmd = &cobra.Command{ 11 Use: "kvdb", 12 Short: "A lightweight, embedded key-value store", 13 Long: ` 14 Kvdb is a lightweight, filesystem-backed key-value store written in Go. 15 By default, kvdb uses the current directory to store data. To get started: 16 17 kvdb set <key> <value> 18 kvdb get <key> 19 `, 20 CompletionOptions: cobra.CompletionOptions{ 21 DisableDefaultCmd: true, 22 }, 23 SilenceUsage: true, 24 } 25 26 // Execute adds all child commands to the root command and sets flags appropriately. 27 // This is called by main.main(). It only needs to happen once to the rootCmd. 28 func Execute() { 29 err := rootCmd.Execute() 30 if err != nil { 31 os.Exit(1) 32 } 33 } 34 35 func init() { 36 // Here you will define your flags and configuration settings. 37 // Cobra supports persistent flags, which, if defined here, 38 // will be global for your application. 39 40 // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.kvdb.yaml)") 41 42 // Cobra also supports local flags, which will only run 43 // when this action is called directly. 44 // rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 45 }