aboutsummaryrefslogtreecommitdiff
path: root/cmd/eno/cobra.go
diff options
context:
space:
mode:
authorishaan <contact@ishaan.cc>2026-07-14 19:26:55 +0530
committerishaan <contact@ishaan.cc>2026-07-14 19:26:55 +0530
commit6c6c4a05267e93597bb009c7d6c36383b6af7bf7 (patch)
tree4c2c85b78b07e877ca18e833d07e8624712e8a4c /cmd/eno/cobra.go
parent9eb2b774e9f0522a3547644453bf929dd560f05f (diff)
ssh
Diffstat (limited to 'cmd/eno/cobra.go')
-rw-r--r--cmd/eno/cobra.go26
1 files changed, 21 insertions, 5 deletions
diff --git a/cmd/eno/cobra.go b/cmd/eno/cobra.go
index 9e4d4d2..ced2bc2 100644
--- a/cmd/eno/cobra.go
+++ b/cmd/eno/cobra.go
@@ -56,7 +56,7 @@ var encryptCmd = &cobra.Command{
crypt.TryMlock(password)
defer clear(password)
- encrypted, err := crypt.EncryptRawBytes(fileBytes, password, crypt.Pass)
+ encrypted, err := crypt.EncryptBytesPass(fileBytes, password)
if err != nil {
cmd.PrintErrln("Error:", err)
os.Exit(1)
@@ -107,7 +107,7 @@ var decryptCmd = &cobra.Command{
crypt.TryMlock(password)
defer clear(password)
- plaintext, err := crypt.DecryptRawBytes(fileBytes, password)
+ plaintext, err := crypt.DecryptBytesPass(fileBytes, password)
if err != nil {
cmd.PrintErrln("Error:", err)
os.Exit(1)
@@ -159,7 +159,21 @@ var editCmd = &cobra.Command{
target = strings.TrimSuffix(target, ".eno")
target += ".eno"
- err = crud.EditNote(target, Conf.EditorString)
+ authMode, err := utils.CheckFileAuthMode(target)
+ if err != nil {
+ cmd.PrintErrln("Error:", err)
+ os.Exit(1)
+ }
+
+ switch authMode {
+ case crypt.SSH:
+ err = crud.EditNoteSSH(target, Conf.DefaultSSHPrivPath, Conf.EditorString)
+ case crypt.Pass:
+ err = crud.EditNotePass(target, Conf.EditorString)
+ default:
+ cmd.PrintErrln("Error: unknown auth mode:", authMode)
+ os.Exit(1)
+ }
if err != nil {
cmd.PrintErrln("Error:", err)
os.Exit(1)
@@ -176,7 +190,9 @@ 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")
+ newCmd.Flags().Bool("ssh", false, "use your ssh for auth")
+
+ sshCmd.AddCommand(sshInitCmd)
- cobraCmd.AddCommand(encryptCmd, decryptCmd, initCmd, newCmd, editCmd)
+ cobraCmd.AddCommand(encryptCmd, decryptCmd, initCmd, newCmd, editCmd, sshCmd)
}