@@ -30,7 +30,79 @@ import (
30
30
"github.com/fatih/color"
31
31
)
32
32
33
- // --sync.server.keyfile
33
+ // --docker.container missing
34
+ func showDockerContainerNameMissingHelp () {
35
+ showFatalHelp (
36
+ "Cannot find docker container name." ,
37
+ "" ,
38
+ "How to solve this:" ,
39
+ "1 - Add a commandline argument:" ,
40
+ "" ,
41
+ " `arangodb ... --docker.container=<name of container you run starter in>`" ,
42
+ "" ,
43
+ )
44
+ }
45
+
46
+ // --cluster.agency-size invalid.
47
+ func showClusterAgencySizeInvalidHelp () {
48
+ showFatalHelp (
49
+ "Cluster agency size is invalid cluster.agency-size needs to be a positive, odd number." ,
50
+ "" ,
51
+ "How to solve this:" ,
52
+ "1 - Use a positive, odd number as agency size:" ,
53
+ "" ,
54
+ " `arangodb ... --cluster.agency-size=<1, 3 or 5...>`" ,
55
+ "" ,
56
+ )
57
+ }
58
+
59
+ // --cluster.agency-size=1 without specifying --starter.address.
60
+ func showClusterAgencySize1WithoutAddressHelp () {
61
+ showFatalHelp (
62
+ "With a cluster agency size of 1, a starter address is required." ,
63
+ "" ,
64
+ "How to solve this:" ,
65
+ "1 - Add a commandline argument:" ,
66
+ "" ,
67
+ " `arangodb ... --starter.address=<IP address of current machine>`" ,
68
+ "" ,
69
+ )
70
+ }
71
+
72
+ // setting both --docker.image and --server.rr is not possible.
73
+ func showDockerImageWithRRIsNotAllowedHelp () {
74
+ showFatalHelp (
75
+ "Using RR is not possible with docker." ,
76
+ "" ,
77
+ "How to solve this:" ,
78
+ "1 - Remove `--server.rr=...` commandline argument." ,
79
+ "" ,
80
+ )
81
+ }
82
+
83
+ // setting both --docker.net-host and --docker.net-mode is not possible
84
+ func showDockerNetHostAndNotModeNotBothAllowedHelp () {
85
+ showFatalHelp (
86
+ "It is not allowed to set `--docker.net-host` and `--docker.net-mode` at the same time." ,
87
+ "" ,
88
+ "How to solve this:" ,
89
+ "1 - Remove one of these two commandline arguments." ,
90
+ "" ,
91
+ )
92
+ }
93
+
94
+ // Arangod is not found at given path.
95
+ func showArangodExecutableNotFoundHelp (arangodPath string ) {
96
+ showFatalHelp (
97
+ fmt .Sprintf ("Cannot find `arangod` (expected at `%s`)." , arangodPath ),
98
+ "" ,
99
+ "How to solve this:" ,
100
+ "1 - Install ArangoDB locally or run the ArangoDB starter in docker. (see RADME for details)." ,
101
+ "" ,
102
+ )
103
+ }
104
+
105
+ // --sync.server.keyfile is missing
34
106
func showSyncMasterServerKeyfileMissingHelp () {
35
107
showFatalHelp (
36
108
"A TLS certificate used for the HTTPS connection of the arangosync syncmaster is missing." ,
@@ -78,14 +150,18 @@ func showSyncMasterClientCAFileMissingHelp() {
78
150
// underneeth and the exit with code 1.
79
151
// Backticks in the lines are colored yellow.
80
152
func showFatalHelp (title string , lines ... string ) {
81
- log .Error (title )
153
+ log .Error (highlight ( title ) )
82
154
content := strings .Join (lines , "\n " )
155
+ fmt .Println (highlight (content ))
156
+ os .Exit (1 )
157
+ }
158
+
159
+ func highlight (content string ) string {
83
160
parts := strings .Split (content , "`" )
84
161
for i , p := range parts {
85
162
if i % 2 == 1 {
86
163
parts [i ] = color .YellowString (p )
87
164
}
88
165
}
89
- fmt .Println (strings .Join (parts , "" ))
90
- os .Exit (1 )
166
+ return strings .Join (parts , "" )
91
167
}
0 commit comments