From 452911586df6115a7c8deadee87fe5d97a7fe36f Mon Sep 17 00:00:00 2001 From: Levi Durfee Date: Tue, 6 Jan 2026 18:33:28 -0500 Subject: Add urfave cli --- cmd/goaes/commands/generate.go | 21 +++++++++++++++++++++ cmd/goaes/main.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 cmd/goaes/commands/generate.go create mode 100644 cmd/goaes/main.go (limited to 'cmd') 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) + } +} -- cgit v1.2.3