cmd/*: refactor get flag value (#24761)

This commit is contained in:
s7v7nislands
2022-04-26 09:32:31 +02:00
committed by GitHub
parent 0914234d10
commit 195c2d3d69
5 changed files with 87 additions and 59 deletions
+4 -2
View File
@@ -34,18 +34,20 @@ import (
"gopkg.in/urfave/cli.v1"
)
var fileFlag = cli.StringFlag{Name: "file"}
var enrdumpCommand = cli.Command{
Name: "enrdump",
Usage: "Pretty-prints node records",
Action: enrdump,
Flags: []cli.Flag{
cli.StringFlag{Name: "file"},
fileFlag,
},
}
func enrdump(ctx *cli.Context) error {
var source string
if file := ctx.String("file"); file != "" {
if file := ctx.String(fileFlag.Name); file != "" {
if ctx.NArg() != 0 {
return fmt.Errorf("can't dump record from command-line argument in -file mode")
}