summaryrefslogtreecommitdiff
path: root/cmd/goaes/main.go
blob: 913317de79adc138d55f3fa74ff1cf976ada55a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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,
			},
			{
				Name:    "encrypt",
				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,
					},
					&cli.StringFlag{
						Name:     "destination",
						Aliases:  []string{"d", "o"},
						Usage:    "where to write the encrypted file",
						Required: true,
					},
				},
			},
			{
				Name:    "decrypt",
				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,
					},
					&cli.StringFlag{
						Name:     "destination",
						Aliases:  []string{"d", "o"},
						Usage:    "where to write the decrypted file",
						Required: true,
					},
				},
			},
		},
	}

	if err := cmd.Run(context.Background(), os.Args); err != nil {
		log.Fatal(err)
	}
}