Skip to content

Commit cefcc94

Browse files
committed
Cleaning up flag declarations
1 parent f4aacb6 commit cefcc94

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

run.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@ func New(cliargs []string) ContextExecutor {
8484
_ = cmd.Flags().Set(f.Name, fmt.Sprintf("%v", v.Get(f.Name)))
8585
}
8686
})
87-
8887
// unhide params
8988
switch {
9089
case bashCompletion,
9190
zshCompletion,
9291
fishCompletion,
9392
powershellCompletion,
9493
cmd.Name() == "__complete":
94+
flags := cmd.Root().Flags()
9595
for _, name := range []string{"no-psqlrc", "no-usqlrc", "var", "variable"} {
96-
cmd.Root().Flags().Lookup(name).Hidden = false
96+
flags.Lookup(name).Hidden = false
9797
}
9898
}
9999
return nil
@@ -118,7 +118,6 @@ func New(cliargs []string) ContextExecutor {
118118
case badHelp:
119119
return errors.New("unknown shorthand flag: 'h' in -h")
120120
}
121-
122121
// run
123122
if len(cliargs) > 0 {
124123
args.DSN = cliargs[0]
@@ -184,7 +183,7 @@ func New(cliargs []string) ContextExecutor {
184183
// set bools
185184
ss(&args.Variables, "quiet", "q", "run quietly (no messages, only query output)", "", "QUIET=on")
186185

187-
// add config
186+
// app config
188187
_ = flags.StringP("config", "", "", "config file")
189188

190189
// manually set --version, see github.com/spf13/cobra/command.go
@@ -211,9 +210,7 @@ func New(cliargs []string) ContextExecutor {
211210
"completion-script-powershell", "no-descriptions",
212211
"bad-help",
213212
} {
214-
if err := flags.MarkHidden(name); err != nil {
215-
panic(err)
216-
}
213+
flags.Lookup(name).Hidden = true
217214
}
218215
return c
219216
}

0 commit comments

Comments
 (0)