diff options
Diffstat (limited to 'cmd/eno/cobra.go')
| -rw-r--r-- | cmd/eno/cobra.go | 70 |
1 files changed, 6 insertions, 64 deletions
diff --git a/cmd/eno/cobra.go b/cmd/eno/cobra.go index b988dab..9e4d4d2 100644 --- a/cmd/eno/cobra.go +++ b/cmd/eno/cobra.go @@ -45,7 +45,7 @@ var encryptCmd = &cobra.Command{ if err != nil { return fmt.Errorf("failed to read input file: %v", err) } - utils.TryMlock(fileBytes) + crypt.TryMlock(fileBytes) defer clear(fileBytes) fmt.Printf("Enter a passphrase: ") @@ -53,10 +53,10 @@ var encryptCmd = &cobra.Command{ if err != nil { return fmt.Errorf("failed to read passphrase: %v", err) } - utils.TryMlock(password) + crypt.TryMlock(password) defer clear(password) - encrypted, err := crypt.EncryptRawBytes(fileBytes, password) + encrypted, err := crypt.EncryptRawBytes(fileBytes, password, crypt.Pass) if err != nil { cmd.PrintErrln("Error:", err) os.Exit(1) @@ -104,7 +104,7 @@ var decryptCmd = &cobra.Command{ if err != nil { return fmt.Errorf("failed to read passphrase: %v", err) } - utils.TryMlock(password) + crypt.TryMlock(password) defer clear(password) plaintext, err := crypt.DecryptRawBytes(fileBytes, password) @@ -112,7 +112,7 @@ var decryptCmd = &cobra.Command{ cmd.PrintErrln("Error:", err) os.Exit(1) } - utils.TryMlock(plaintext) + crypt.TryMlock(plaintext) defer clear(plaintext) if err := os.WriteFile(output, plaintext, 0644); err != nil { @@ -138,65 +138,6 @@ var initCmd = &cobra.Command{ }, } -var newCmd = &cobra.Command{ - Use: "new <note>", - Short: "create a new encrypted note", - Args: cobra.MinimumNArgs(1), - Run: func(cmd *cobra.Command, args []string) { - output, err := cmd.Flags().GetString("output") - if err != nil { - cmd.PrintErrln("Error:", err) - os.Exit(1) - } - - editFlag, err := cmd.Flags().GetBool("edit") - if err != nil { - cmd.PrintErrln("Error:", err) - os.Exit(1) - } - - noteName := strings.Join(args, " ") - - if output == "" { - if strings.ContainsRune(noteName, filepath.Separator) { - output = noteName + ".eno" - } else { - output = filepath.Join(Conf.DataDir, noteName+".eno") - } - } - - if _, err := os.Stat(output); err == nil { - ok, err := utils.AskUserYesNo("file '"+output+"' already exists. Overwrite?", false) - if err != nil { - cmd.PrintErrln("Error:", err) - os.Exit(1) - } - if !ok { - cmd.PrintErrln("Error: write aborted") - os.Exit(1) - } - } - - err = crud.NewNote(output) - if err != nil { - cmd.PrintErrln("Error:", err) - os.Exit(1) - } - - if editFlag { - target := filepath.Clean(output) - target = strings.TrimSuffix(target, ".eno") - target += ".eno" - - err = crud.EditNote(target, Conf.EditorString) - if err != nil { - cmd.PrintErrln("Error:", err) - os.Exit(1) - } - } - }, -} - var editCmd = &cobra.Command{ Use: "edit <note>", Short: "edit an existing encrypted note", @@ -235,6 +176,7 @@ func init() { newCmd.Flags().StringP("output", "o", "", "output file") newCmd.Flags().BoolP("edit", "e", false, "edit after creation") + newCmd.Flags().BoolP("ssh", "ssh", false, "use your ssh for auth") cobraCmd.AddCommand(encryptCmd, decryptCmd, initCmd, newCmd, editCmd) } |