Skip to content

Commit 79e5c28

Browse files
Merge pull request #44 from ipfs/migration-without-path
Migration without path
2 parents 7220418 + 3b21674 commit 79e5c28

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

go-migrate/cli.go

Lines changed: 8 additions & 1 deletion
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,9 +31,14 @@ 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()
34-
return nil
41+
return fmt.Errorf("missing or empty path; flag '-path <ipfs_path>' is required")
3542
}
3643

3744
if !m.Reversible() {
File renamed without changes.
File renamed without changes.

sharness/t0080-three-to-four.sh renamed to sharness/t0080-migration-3-to-4.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ test_expect_success "get pin lists" '
223223
ipfs pin ls --type=indirect | sort > more_start_ind_pins
224224
'
225225

226+
test_expect_success "'ipfs-3-to-4 -revert' fails without -path" '
227+
test_must_fail ipfs-3-to-4 -revert
228+
'
229+
226230
test_expect_success "'ipfs-3-to-4 -revert' succeeds" '
227231
ipfs-3-to-4 -revert -path="$IPFS_PATH" >actual
228232
'

0 commit comments

Comments
 (0)