From 65017dfaff1376a16f4d11e76a8aa2d625e05aec Mon Sep 17 00:00:00 2001 From: ishaan Date: Sun, 12 Jul 2026 06:40:42 +0530 Subject: no step on snek --- cmd/eno/cobra.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 cmd/eno/cobra.go (limited to 'cmd/eno/cobra.go') 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 ", + 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 ", + 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) +} -- cgit v1.3