diff options
| author | Levi Durfee <levi.durfee@gmail.com> | 2026-01-08 18:14:50 -0500 |
|---|---|---|
| committer | Levi Durfee <levi.durfee@gmail.com> | 2026-01-08 18:19:26 -0500 |
| commit | 496c557b041ae17557c99e8a0092e21431a2242d (patch) | |
| tree | 81a3769dcd822245ae3ac20b05bb4ac510436d43 /cmd | |
| parent | 6bf86ba37918b918cd8bf432757c00f69d35b85f (diff) | |
Simplify encrypt command
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/goaes/commands/encrypt.go | 8 | ||||
| -rw-r--r-- | cmd/goaes/main.go | 16 |
2 files changed, 11 insertions, 13 deletions
diff --git a/cmd/goaes/commands/encrypt.go b/cmd/goaes/commands/encrypt.go index df707cb..223502b 100644 --- a/cmd/goaes/commands/encrypt.go +++ b/cmd/goaes/commands/encrypt.go @@ -12,8 +12,12 @@ import ( ) func Encrypt(ctx context.Context, cmd *cli.Command) error { - source := cmd.String("source") - destination := cmd.String("destination") + source := cmd.StringArg("source") + destination := cmd.StringArg("destination") + + if destination == "" { + destination = source + ".goaes" + } source = filepath.Clean(source) plaintext, err := os.ReadFile(source) diff --git a/cmd/goaes/main.go b/cmd/goaes/main.go index df89eed..770fb57 100644 --- a/cmd/goaes/main.go +++ b/cmd/goaes/main.go @@ -33,18 +33,12 @@ func main() { Aliases: []string{"e"}, Usage: "Encrypt a file", Action: commands.Encrypt, - Flags: []cli.Flag{ - &cli.StringFlag{ - Name: "source", - Aliases: []string{"s", "i"}, - Usage: "source file to encrypt", - Required: true, + Arguments: []cli.Argument{ + &cli.StringArg{ + Name: "source", }, - &cli.StringFlag{ - Name: "destination", - Aliases: []string{"d", "o"}, - Usage: "where to write the encrypted file", - Required: true, + &cli.StringArg{ + Name: "destination", }, }, }, |
