Use os.Args[0] in usage strings instead of hardcoded names · Entire
Use os.Args[0] in usage strings instead of hardcoded names
7d69a31→main·
pjbgf·2mo ago·2 files·+9 added/-9 removed
Keeps usage output accurate when the binary is renamed or invoked through a different path.
Assisted-by: Claude Opus 4.7 noreply@anthropic.com Signed-off-by: Paulo Gomes paulo@entire.io
Sessions
e8ae87b8f128View transcript
Changes
2
cmd
git-sync-bench
Mmain.go+1/-1
git-sync
Mmain.go+8/-8
449 unmodified lines
450
451
452
453
453
454
455
456
449 unmodified lines
}
func usageError(message string) error {
usage := "usage:\n git-sync-bench --source-url <repo> [flags]\n\nflags:\n --scenario bootstrap|sync\n --repeat 3\n --work-dir /tmp/git-sync-bench\n --keep-targets\n --json\n --branch main,release\n --map main:stable\n --tags\n --force\n --prune\n --stats\n --measure-memory\n --max-pack-bytes 104857600\n --target-max-pack-bytes 104857600\n --protocol auto|v1|v2\n -v\n"
usage := fmt.Sprintf("usage:\n %s --source-url <repo> [flags]\n\nflags:\n --scenario bootstrap|sync\n --repeat 3\n --work-dir /tmp/git-sync-bench\n --keep-targets\n --json\n --branch main,release\n --map main:stable\n --tags\n --force\n --prune\n --stats\n --measure-memory\n --max-pack-bytes 104857600\n --target-max-pack-bytes 104857600\n --protocol auto|v1|v2\n -v\n", os.Args[0])
if message == "" {
return errors.New(strings.TrimSpace(usage))
}
}
Mcmd/git-sync-bench/main.go+1/-1
424 unmodified lines
425
426
427
428
429
430
431
432
433
428
429
430
431
432
433
434
435
436
4 unmodified lines
441
442
443
444
444
445
446
447
110 unmodified lines
558
559
560
561
561
562
563
564
424 unmodified lines
func usageError(message string) error {
usage := fmt.Sprintf(`usage:
git-sync sync [flags] <source-url> <target-url>
git-sync replicate [flags] <source-url> <target-url>
git-sync plan [flags] <source-url> <target-url>
git-sync bootstrap [flags] <source-url> <target-url>
git-sync probe [flags] <source-url> [target-url]
git-sync fetch [flags] <source-url>
%[1]s sync [flags] <source-url> <target-url>
%[1]s replicate [flags] <source-url> <target-url>
%[1]s plan [flags] <source-url> <target-url>
%[1]s bootstrap [flags] <source-url> <target-url>
%[1]s probe [flags] <source-url> [target-url]
%[1]s fetch [flags] <source-url>
sync flags:
--branch main,dev
-v
--stats
--measure-memory
--json
--materialized-max-objects %d
--materialized-max-objects %[2]d
--max-pack-bytes <bytes>
--target-max-pack-bytes <bytes>
--protocol auto|v1|v2
`, unstable.DefaultMaterializedMaxObjects)
`, os.Args[0], unstable.DefaultMaterializedMaxObjects)
if message == "" {
return errors.New(strings.TrimSpace(usage))
}
}
Mcmd/git-sync/main.go+8/-8