@@ -58,11 +58,18 @@ var (
5858 projectVersion = "dev"
5959 projectBuild = "dev"
6060 cmdMain = cobra.Command {
61- Use : projectName ,
62- Short : "Start ArangoDB clusters & single servers with ease" ,
63- Run : cmdMainRun ,
61+ Use : projectName ,
62+ Short : "Start ArangoDB clusters & single servers with ease" ,
63+ Run : cmdMainRun ,
64+ PersistentPreRun : cmdShowVersionRun ,
65+ }
66+ cmdVersion = & cobra.Command {
67+ Use : "version" ,
68+ Short : "Show ArangoDB version" ,
69+ Run : cmdShowVersionRun ,
6470 }
6571 log = logging .MustGetLogger (projectName )
72+ showVersion bool
6673 id string
6774 agencySize int
6875 arangodPath string
@@ -107,8 +114,12 @@ var (
107114)
108115
109116func init () {
117+ cmdMain .AddCommand (cmdVersion )
118+
110119 f := cmdMain .PersistentFlags ()
111120
121+ f .BoolVar (& showVersion , "version" , false , "If set, show version and exit" )
122+
112123 f .StringSliceVar (& masterAddresses , "starter.join" , nil , "join a cluster with master at given address" )
113124 f .StringVar (& mode , "starter.mode" , "cluster" , "Set the mode of operation to use (cluster|single)" )
114125 f .BoolVar (& startLocalSlaves , "starter.local" , false , "If set, local slaves will be started to create a machine local (test) cluster" )
@@ -320,6 +331,13 @@ func main() {
320331 cmdMain .Execute ()
321332}
322333
334+ func cmdShowVersionRun (cmd * cobra.Command , args []string ) {
335+ if cmd .Use == "version" || showVersion {
336+ fmt .Printf ("Version %s, build %s\n " , projectVersion , projectBuild )
337+ os .Exit (0 )
338+ }
339+ }
340+
323341func cmdMainRun (cmd * cobra.Command , args []string ) {
324342 log .Infof ("Starting %s version %s, build %s" , projectName , projectVersion , projectBuild )
325343
0 commit comments