@@ -13,8 +13,13 @@ import (
13
13
14
14
const rootCommandName = "git-bug-migration"
15
15
16
+ type rootOpts struct {
17
+ forReal bool
18
+ }
19
+
16
20
func NewRootCommand () * cobra.Command {
17
21
env := newEnv ()
22
+ opts := rootOpts {}
18
23
19
24
migrations := []Migration {
20
25
& migration1.Migration1 {},
@@ -36,19 +41,30 @@ To migrate a repository, go to the corresponding repository and run "git-bug-mig
36
41
37
42
PreRunE : findRepo (env ),
38
43
RunE : func (_ * cobra.Command , _ []string ) error {
39
- return runRootCmd (env , migrations )
44
+ return runRootCmd (env , opts , migrations )
40
45
},
41
46
42
47
SilenceUsage : true ,
43
48
DisableAutoGenTag : true ,
44
49
}
45
50
51
+ flags := cmd .Flags ()
52
+ flags .BoolVar (& opts .forReal , "for-real" , false , "Indicate that your really want to run this tool and possibly ruin your data." )
53
+
46
54
cmd .AddCommand (newVersionCommand ())
47
55
48
56
return cmd
49
57
}
50
58
51
- func runRootCmd (env * Env , migrations []Migration ) error {
59
+ func runRootCmd (env * Env , opts rootOpts , migrations []Migration ) error {
60
+ if ! opts .forReal {
61
+ env .err .Println ("DISCLAIMER: This tool exist for your convenience to migrate your data and allow git-bug's authors" +
62
+ " to break things and make it better. However, this migration tool is quite crude and experimental. DO NOT TRUST IT BLINDLY.\n \n " +
63
+ "Please make a backup of your .git folder before running it.\n \n " +
64
+ "When done, run this tool again with the --for-real flag." )
65
+ os .Exit (1 )
66
+ }
67
+
52
68
for i , migration := range migrations {
53
69
if i > 0 {
54
70
env .out .Println ()
0 commit comments