use cli flag action like it should be

This commit is contained in:
Lilian Jónsdóttir 2024-03-19 10:49:02 -07:00
parent 5a96e79694
commit 37601be04f

View file

@ -49,8 +49,8 @@ var (
Name: "identity", Name: "identity",
Usage: "age identity file to use", Usage: "age identity file to use",
Aliases: []string{"i"}, Aliases: []string{"i"},
Action: func(ctx *cli.Context, s string) error { Action: func(ctx *cli.Context, identity_file string) error {
if identity_file := ctx.String("identity"); identity_file != "" { if identity_file != "" {
cfg.IdentityFile = identity_file cfg.IdentityFile = identity_file
} }
return nil return nil
@ -60,8 +60,8 @@ var (
Name: "out", Name: "out",
Usage: "write to this file instead of the input file", Usage: "write to this file instead of the input file",
Aliases: []string{"o"}, Aliases: []string{"o"},
Action: func(ctx *cli.Context, s string) error { Action: func(ctx *cli.Context, out string) error {
output_file = ctx.String("out") output_file = out
return nil return nil
}, },
}, },
@ -71,7 +71,7 @@ var (
Value: "warn", Value: "warn",
Aliases: []string{"l"}, Aliases: []string{"l"},
Action: func(ctx *cli.Context, s string) error { Action: func(ctx *cli.Context, s string) error {
if lvl, err := log.ParseLevel(ctx.String("log")); err == nil { if lvl, err := log.ParseLevel(s); err == nil {
logger.SetLevel(lvl) logger.SetLevel(lvl)
// Some extra info for debug level // Some extra info for debug level
if logger.GetLevel() == log.DebugLevel { if logger.GetLevel() == log.DebugLevel {
@ -87,8 +87,8 @@ var (
Name: "editor", Name: "editor",
Usage: "specify the editor to use", Usage: "specify the editor to use",
Aliases: []string{"e"}, Aliases: []string{"e"},
Action: func(ctx *cli.Context, s string) error { Action: func(ctx *cli.Context, editor string) error {
cfg.Editor = ctx.String("editor") cfg.Editor = editor
return nil return nil
}, },
}, },