From 6b24f73fb3c71062321aa1f7f9694b42b7299a6a Mon Sep 17 00:00:00 2001 From: Levi Durfee Date: Thu, 8 Jan 2026 18:21:45 -0500 Subject: Simplify decrypt command --- cmd/goaes/commands/decrypt.go | 12 ++++++++++-- cmd/goaes/main.go | 16 +++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cmd/goaes/commands/decrypt.go b/cmd/goaes/commands/decrypt.go index 9168a00..1fcd83e 100644 --- a/cmd/goaes/commands/decrypt.go +++ b/cmd/goaes/commands/decrypt.go @@ -12,8 +12,16 @@ import ( ) func Decrypt(ctx context.Context, cmd *cli.Command) error { - source := cmd.String("source") - destination := cmd.String("destination") + source := cmd.StringArg("source") + destination := cmd.StringArg("destination") + + if source == "" { + return cli.Exit("missing source", 2) + } + + if destination == "" { + return cli.Exit("missing destination", 2) + } source = filepath.Clean(source) file, err := os.Open(source) diff --git a/cmd/goaes/main.go b/cmd/goaes/main.go index 770fb57..2722099 100644 --- a/cmd/goaes/main.go +++ b/cmd/goaes/main.go @@ -47,18 +47,12 @@ func main() { Aliases: []string{"d"}, Usage: "Decrypt a file", Action: commands.Decrypt, - Flags: []cli.Flag{ - &cli.StringFlag{ - Name: "source", - Aliases: []string{"s", "i"}, - Usage: "source file to decrypt", - Required: true, + Arguments: []cli.Argument{ + &cli.StringArg{ + Name: "source", }, - &cli.StringFlag{ - Name: "destination", - Aliases: []string{"d", "o"}, - Usage: "where to write the decrypted file", - Required: true, + &cli.StringArg{ + Name: "destination", }, }, }, -- cgit v1.2.3