summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorLevi Durfee <levi.durfee@gmail.com>2026-01-06 18:33:28 -0500
committerLevi Durfee <levi.durfee@gmail.com>2026-01-06 18:55:09 -0500
commit452911586df6115a7c8deadee87fe5d97a7fe36f (patch)
tree6e0979813a7106a36b46e4ca1e289fa35049c969 /cmd
parent7a3184afc17a267a2a140e6ab95d7fe57f91cb69 (diff)
Add urfave cli
Diffstat (limited to 'cmd')
-rw-r--r--cmd/goaes/commands/generate.go21
-rw-r--r--cmd/goaes/main.go32
2 files changed, 53 insertions, 0 deletions
diff --git a/cmd/goaes/commands/generate.go b/cmd/goaes/commands/generate.go
new file mode 100644
index 0000000..2ce2400
--- /dev/null
+++ b/cmd/goaes/commands/generate.go
@@ -0,0 +1,21 @@
+package commands
+
+import (
+ "context"
+ "encoding/base64"
+ "fmt"
+
+ "github.com/nerdsec/goaes/internal"
+ "github.com/urfave/cli/v3"
+)
+
+func Generate(ctx context.Context, cmd *cli.Command) error {
+ key, err := internal.NewDEK()
+ if err != nil {
+ return err
+ }
+
+ fmt.Println(base64.StdEncoding.EncodeToString(key))
+
+ return nil
+}
diff --git a/cmd/goaes/main.go b/cmd/goaes/main.go
new file mode 100644
index 0000000..30f1d1d
--- /dev/null
+++ b/cmd/goaes/main.go
@@ -0,0 +1,32 @@
+package main
+
+import (
+ "context"
+ "log"
+ "os"
+
+ "github.com/nerdsec/goaes/cmd/goaes/commands"
+ "github.com/urfave/cli/v3"
+)
+
+func main() {
+ cmd := &cli.Command{
+ Name: "goaes",
+ Usage: "Simple AES encryption built with Go",
+ Action: func(ctx context.Context, cmd *cli.Command) error {
+ return cli.DefaultShowRootCommandHelp(cmd)
+ },
+ Commands: []*cli.Command{
+ {
+ Name: "generate",
+ Aliases: []string{"g"},
+ Usage: "Generate a base64 encoded key",
+ Action: commands.Generate,
+ },
+ },
+ }
+
+ if err := cmd.Run(context.Background(), os.Args); err != nil {
+ log.Fatal(err)
+ }
+}