AT Protocol IPLD-CAR Repository toolkit (CLI)
at main 1.3 kB view raw
1package cmd 2 3import ( 4 "fmt" 5 6 "github.com/atscan/atr/util/version" 7 "github.com/spf13/cobra" 8) 9 10var ( 11 // Used for flags. 12 //cfgFile string 13 workingDir string 14 15 rootCmd = &cobra.Command{ 16 Use: "atr", 17 Short: "AT Protocol IPLD-CAR Repository toolkit", 18 //Long: `.`, 19 } 20) 21 22// Execute executes the root command. 23func Execute() error { 24 return rootCmd.Execute() 25} 26 27func init() { 28 //cobra.OnInitialize(initConfig) 29 30 rootCmd.PersistentFlags().StringVarP(&workingDir, "working-dir", "C", ".", "") 31 32 //rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)") 33 rootCmd.AddCommand(versionCmd) 34 //rootCmd.AddCommand(ShowCmd) 35} 36 37/*func initConfig() { 38 if cfgFile != "" { 39 // Use config file from the flag. 40 //viper.SetConfigFile(cfgFile) 41 } else { 42 // Find home directory. 43 //home, err := os.UserHomeDir() 44 //cobra.CheckErr(err) 45 46 viper.AddConfigPath(home) 47 viper.SetConfigType("yaml") 48 viper.SetConfigName(".atr") 49 } 50 51 //viper.AutomaticEnv() 52 53 if err := viper.ReadInConfig(); err == nil { 54 fmt.Println("Using config file:", viper.ConfigFileUsed()) 55 } 56}*/ 57 58var versionCmd = &cobra.Command{ 59 Use: "version", 60 Short: "Print the version number", 61 Run: func(cmd *cobra.Command, args []string) { 62 fmt.Println(version.Version("")) 63 }, 64}