Skip to content

Commit 3b21674

Browse files
committed
ipfs-3-to-4: add --help flag
This also makes sure we exit with code 0 when using --help.
1 parent 36a3233 commit 3b21674

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

go-migrate/cli.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ type Flags struct {
1111
Revert bool
1212
Path string // file path to migrate for fs based migrations
1313
Verbose bool
14+
Help bool
1415
}
1516

1617
func (f *Flags) Setup() {
1718
flag.BoolVar(&f.Force, "f", false, "whether to force a migration (ignores warnings)")
1819
flag.BoolVar(&f.Revert, "revert", false, "whether to apply the migration backwards")
1920
flag.BoolVar(&f.Verbose, "verbose", false, "enable verbose logging")
21+
flag.BoolVar(&f.Help, "help", false, "display help message")
2022
flag.StringVar(&f.Path, "path", "", "file path to migrate for fs based migrations (required)")
2123
}
2224

@@ -29,6 +31,11 @@ func Run(m Migration) error {
2931
f.Setup()
3032
f.Parse()
3133

34+
if f.Help {
35+
flag.Usage()
36+
os.Exit(0)
37+
}
38+
3239
if f.Path == "" {
3340
flag.Usage()
3441
return fmt.Errorf("missing or empty path; flag '-path <ipfs_path>' is required")

0 commit comments

Comments
 (0)