Skip to content

Commit b44302a

Browse files
authored
Merge pull request #86 from arangodb-helper/show-version
Added `--version` option & `version` command
2 parents d4b9d52 + b3fd1cf commit b44302a

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Changes from version 0.9.2 to 0.9.3
2+
3+
- Added `--version` option and `version` command to show version of the starter.
4+
15
# Changes from version 0.9.1 to 0.9.2
26

37
- Added `--starter.disable-ipv6` option to cope with environments

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ arangodb --coordinators.log.level=requests=debug
374374
Esoteric options
375375
----------------
376376

377+
* `--version`
378+
379+
show the version of the starter.
380+
377381
* `--starter.port=int`
378382

379383
port for arangodb master (default 8528). See below under "Technical

main.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

109116
func 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+
323341
func cmdMainRun(cmd *cobra.Command, args []string) {
324342
log.Infof("Starting %s version %s, build %s", projectName, projectVersion, projectBuild)
325343

0 commit comments

Comments
 (0)