diff options
| author | ishaan <contact@ishaan.cc> | 2026-07-12 06:40:42 +0530 |
|---|---|---|
| committer | ishaan <contact@ishaan.cc> | 2026-07-12 06:40:42 +0530 |
| commit | 65017dfaff1376a16f4d11e76a8aa2d625e05aec (patch) | |
| tree | ab099d2b5d037e2670e6761c99a506accaef78d8 /cmd/eno/cobra.go | |
| parent | cfbacac3872a98303481a7930b8d497058499b30 (diff) | |
no step on snek
Diffstat (limited to 'cmd/eno/cobra.go')
| -rw-r--r-- | cmd/eno/cobra.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/cmd/eno/cobra.go b/cmd/eno/cobra.go new file mode 100644 index 0000000..1199aa0 --- /dev/null +++ b/cmd/eno/cobra.go @@ -0,0 +1,50 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +var cobraCmd = &cobra.Command{ + Use: "eno", + Short: "file encryption tool", +} + +var encryptCmd = &cobra.Command{ + Use: "encrypt <file>", + Short: "encrypt a file", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + output, _ := cmd.Flags().GetString("output") + if output == "" { + return fmt.Errorf("output file required (-o)") + } + rawEncryptFile(args[0], output) + return nil + }, +} + +var decryptCmd = &cobra.Command{ + Use: "decrypt <file>", + Short: "decrypt a file", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + output, _ := cmd.Flags().GetString("output") + if output == "" { + return fmt.Errorf("output file required (-o)") + } + rawDecryptFile(args[0], output) + return nil + }, +} + +func init() { + encryptCmd.Flags().StringP("output", "o", "", "output file (required)") + encryptCmd.MarkFlagRequired("output") + + decryptCmd.Flags().StringP("output", "o", "", "output file (required)") + decryptCmd.MarkFlagRequired("output") + + cobraCmd.AddCommand(encryptCmd, decryptCmd) +} |