Skip to content

Commit 97a5488

Browse files
authored
Merge pull request #207 from thockin/flag-help
Better flag help strings
2 parents 147a5f5 + dc5bdcb commit 97a5488

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

cmd/git-sync/main.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,50 +56,50 @@ var flDepth = flag.Int("depth", envInt("GIT_SYNC_DEPTH", 0),
5656
"use a shallow clone with a history truncated to the specified number of commits")
5757

5858
var flRoot = flag.String("root", envString("GIT_SYNC_ROOT", envString("HOME", "")+"/git"),
59-
"the root directory for git operations")
59+
"the root directory for git-sync operations, under which --dest will be created")
6060
var flDest = flag.String("dest", envString("GIT_SYNC_DEST", ""),
61-
"the name at which to publish the checked-out files under --root (defaults to leaf dir of --repo)")
61+
"the name of (a symlink to) a directory in which to check-out files under --root (defaults to the leaf dir of --repo)")
6262
var flWait = flag.Float64("wait", envFloat("GIT_SYNC_WAIT", 0),
6363
"the number of seconds between syncs")
6464
var flSyncTimeout = flag.Int("timeout", envInt("GIT_SYNC_TIMEOUT", 120),
65-
"the max number of seconds for a complete sync")
65+
"the max number of seconds allowed for a complete sync")
6666
var flOneTime = flag.Bool("one-time", envBool("GIT_SYNC_ONE_TIME", false),
67-
"exit after the initial checkout")
67+
"exit after the first sync")
6868
var flMaxSyncFailures = flag.Int("max-sync-failures", envInt("GIT_SYNC_MAX_SYNC_FAILURES", 0),
69-
"the number of consecutive failures allowed before aborting (the first pull must succeed, -1 disables aborting for any number of failures after the initial sync)")
69+
"the number of consecutive failures allowed before aborting (the first sync must succeed, -1 will retry forever after the initial sync)")
7070
var flChmod = flag.Int("change-permissions", envInt("GIT_SYNC_PERMISSIONS", 0),
71-
"the file permissions to apply to the checked-out files")
71+
"the file permissions to apply to the checked-out files (0 will not change permissions at all)")
7272

7373
var flWebhookURL = flag.String("webhook-url", envString("GIT_SYNC_WEBHOOK_URL", ""),
74-
"the URL for the webook to send to. Default is \"\" which disables the webook.")
74+
"the URL for a webook notification when syncs complete (default is no webook)")
7575
var flWebhookMethod = flag.String("webhook-method", envString("GIT_SYNC_WEBHOOK_METHOD", "POST"),
76-
"the method for the webook to send with")
76+
"the HTTP method for the webook")
7777
var flWebhookStatusSuccess = flag.Int("webhook-success-status", envInt("GIT_SYNC_WEBHOOK_SUCCESS_STATUS", 200),
78-
"the status code which indicates a successful webhook call. A value of -1 disables success checks to make webhooks fire-and-forget")
78+
"the HTTP status code indicating a successful webhook (-1 disables success checks to make webhooks fire-and-forget)")
7979
var flWebhookTimeout = flag.Duration("webhook-timeout", envDuration("GIT_SYNC_WEBHOOK_TIMEOUT", time.Second),
80-
"the timeout used when communicating with the webhook target")
80+
"the timeout for the webhook")
8181
var flWebhookBackoff = flag.Duration("webhook-backoff", envDuration("GIT_SYNC_WEBHOOK_BACKOFF", time.Second*3),
82-
"if a webhook call fails (dependant on webhook-success-status) this defines how much time to wait before retrying the call")
82+
"the time to wait before retrying a failed webhook")
8383

8484
var flUsername = flag.String("username", envString("GIT_SYNC_USERNAME", ""),
85-
"the username to use")
85+
"the username to use for git auth")
8686
var flPassword = flag.String("password", envString("GIT_SYNC_PASSWORD", ""),
87-
"the password to use")
87+
"the password to use for git auth (users should prefer env vars for passwords)")
8888

8989
var flSSH = flag.Bool("ssh", envBool("GIT_SYNC_SSH", false),
9090
"use SSH for git operations")
9191
var flSSHKeyFile = flag.String("ssh-key-file", envString("GIT_SSH_KEY_FILE", "/etc/git-secret/ssh"),
92-
"the ssh key to use")
92+
"the SSH key to use")
9393
var flSSHKnownHosts = flag.Bool("ssh-known-hosts", envBool("GIT_KNOWN_HOSTS", true),
9494
"enable SSH known_hosts verification")
9595
var flSSHKnownHostsFile = flag.String("ssh-known-hosts-file", envString("GIT_SSH_KNOWN_HOSTS_FILE", "/etc/git-secret/known_hosts"),
96-
"the known hosts file to use")
96+
"the known_hosts file to use")
9797

9898
var flCookieFile = flag.Bool("cookie-file", envBool("GIT_COOKIE_FILE", false),
9999
"use git cookiefile")
100100

101101
var flGitCmd = flag.String("git", envString("GIT_SYNC_GIT", "git"),
102-
"the git command to run (subject to PATH search)")
102+
"the git command to run (subject to PATH search, mostly for testing)")
103103

104104
var flHTTPBind = flag.String("http-bind", envString("GIT_SYNC_HTTP_BIND", ""),
105105
"the bind address (including port) for git-sync's HTTP endpoint")
@@ -212,7 +212,7 @@ func main() {
212212
}
213213

214214
if *flRepo == "" {
215-
fmt.Fprintf(os.Stderr, "ERROR: --repo or $GIT_SYNC_REPO must be provided\n")
215+
fmt.Fprintf(os.Stderr, "ERROR: --repo must be provided\n")
216216
flag.Usage()
217217
os.Exit(1)
218218
}
@@ -234,7 +234,7 @@ func main() {
234234
}
235235

236236
if (*flUsername != "" || *flPassword != "" || *flCookieFile) && *flSSH {
237-
fmt.Fprintf(os.Stderr, "ERROR: GIT_SYNC_SSH set but HTTP parameters provided. These cannot be used together.")
237+
fmt.Fprintf(os.Stderr, "ERROR: --ssh is set but --username, --password, or --cookie-file were provided\n")
238238
os.Exit(1)
239239
}
240240

0 commit comments

Comments
 (0)