Skip to content
This repository was archived by the owner on Sep 9, 2022. It is now read-only.

Commit 6d772d3

Browse files
committed
create secman delete command in app package
1 parent cfef27b commit 6d772d3

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

app/delete.go

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package app
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/spf13/cobra"
8+
tea "github.com/charmbracelet/bubbletea"
9+
"github.com/scmn-dev/secman/pkg/pipe/delete"
10+
)
11+
12+
func DeleteCMD() *cobra.Command {
13+
cmd := &cobra.Command{
14+
Use: "delete",
15+
Aliases: []string{"del", "rm", "remove"},
16+
Short: "Delete a password from your vault.",
17+
Long: `Delete a password from your vault.`,
18+
RunE: func(cmd *cobra.Command, args []string) error {
19+
if len(args) > 0 {
20+
PwOpts.Password = args[0]
21+
}
22+
23+
if err := tea.NewProgram(delete.Delete(&PwOpts)).Start(); err != nil {
24+
fmt.Printf("could not start program: %s\n", err)
25+
os.Exit(1)
26+
}
27+
28+
return nil
29+
},
30+
}
31+
32+
cmd.Flags().BoolVarP(&PwOpts.Logins, "logins", "l", false, "Delete password from logins type.")
33+
cmd.Flags().BoolVarP(&PwOpts.CreditCards, "credit-cards", "c", false, "Delete password from credit cards type.")
34+
cmd.Flags().BoolVarP(&PwOpts.Emails, "emails", "e", false, "Delete password from emails type.")
35+
cmd.Flags().BoolVarP(&PwOpts.Notes, "notes", "n", false, "Delete password from notes type.")
36+
cmd.Flags().BoolVarP(&PwOpts.Servers, "servers", "s", false, "Delete password from servers type.")
37+
38+
return cmd
39+
}

0 commit comments

Comments
 (0)