@@ -77,29 +77,43 @@ var rootCmdFlags struct {
7777 ConfigFile string
7878}
7979
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 {
8282 Use : "arduino" ,
8383 Short : "Arduino CLI" ,
8484 Long : "Arduino Create Command Line Interface (arduino-cli)" ,
8585 BashCompletionFunction : bashAutoCompletionFunction ,
8686}
8787
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+
88101// Execute adds all child commands to the root command sets flags appropriately.
89102// This is called by main.main(). It only needs to happen once to the rootCmd.
90103func Execute () {
91- if err := RootCmd .Execute (); err != nil {
92- //fmt.Println( err)
104+ err := arduinoCmd .Execute ()
105+ if err != nil {
93106 os .Exit (1 )
94107 }
95108}
96109
97110func init () {
98111 cobra .OnInitialize (initConfig )
99112
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)" )
101115
102- RootCmd . Flags (). StringVar ( & rootCmdFlags . ConfigFile , "config" , "" , "config file (default is $HOME/.arduino-cli.yaml)" )
116+ arduinoCmd . AddCommand ( arduinoVersionCmd )
103117}
104118
105119// initConfig reads in config file and ENV variables if set.
0 commit comments