@@ -77,29 +77,43 @@ var rootCmdFlags struct {
77
77
ConfigFile string
78
78
}
79
79
80
- // RootCmd represents the base command when called without any subcommands
81
- var RootCmd = & cobra.Command {
80
+ // arduinoCmd represents the base command when called without any subcommands
81
+ var arduinoCmd = & cobra.Command {
82
82
Use : "arduino" ,
83
83
Short : "Arduino CLI" ,
84
84
Long : "Arduino Create Command Line Interface (arduino-cli)" ,
85
85
BashCompletionFunction : bashAutoCompletionFunction ,
86
86
}
87
87
88
+ // arduinoVersionCmd represents the version command.
89
+ var arduinoVersionCmd = & cobra.Command {
90
+ Use : "version" ,
91
+ Short : "Shows version Number of arduino" ,
92
+ Long : `Shows version Number of arduino which is installed on your system.` ,
93
+ Run : func (cmd * cobra.Command , args []string ) {
94
+ fmt .Printf ("arduino V. %s\n " , ArduinoVersion )
95
+ if GlobalFlags .Verbose > 0 {
96
+ fmt .Printf ("arduino V. %s\n " , LibVersion )
97
+ }
98
+ },
99
+ }
100
+
88
101
// Execute adds all child commands to the root command sets flags appropriately.
89
102
// This is called by main.main(). It only needs to happen once to the rootCmd.
90
103
func Execute () {
91
- if err := RootCmd .Execute (); err != nil {
92
- //fmt.Println( err)
104
+ err := arduinoCmd .Execute ()
105
+ if err != nil {
93
106
os .Exit (1 )
94
107
}
95
108
}
96
109
97
110
func init () {
98
111
cobra .OnInitialize (initConfig )
99
112
100
- RootCmd .PersistentFlags ().CountVarP (& GlobalFlags .Verbose , "verbose" , "v" , "enables verbose output (use more times for a higher level)" )
113
+ arduinoCmd .PersistentFlags ().CountVarP (& GlobalFlags .Verbose , "verbose" , "v" , "enables verbose output (use more times for a higher level)" )
114
+ arduinoCmd .Flags ().StringVar (& rootCmdFlags .ConfigFile , "config" , "" , "config file (default is $HOME/.arduino-cli.yaml)" )
101
115
102
- RootCmd . Flags (). StringVar ( & rootCmdFlags . ConfigFile , "config" , "" , "config file (default is $HOME/.arduino-cli.yaml)" )
116
+ arduinoCmd . AddCommand ( arduinoVersionCmd )
103
117
}
104
118
105
119
// initConfig reads in config file and ENV variables if set.
0 commit comments