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

Commit

Permalink
update: add --tree-view flag to secman list command, update sumfile
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Mar 18, 2022
1 parent bf3a3e5 commit 685c19b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 949 deletions.
42 changes: 39 additions & 3 deletions app/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ package app
import (
"os"
"fmt"
"time"
"strings"

"github.com/abdfnx/gosh"
"github.com/spf13/cobra"
"github.com/briandowns/spinner"
"github.com/charmbracelet/lipgloss"
"github.com/scmn-dev/secman/constants"
tea "github.com/charmbracelet/bubbletea"
"github.com/scmn-dev/secman/internal/shared"
"github.com/scmn-dev/secman/pkg/pipe/lister"
)

Expand All @@ -16,14 +23,43 @@ func ListCMD() *cobra.Command {
Long: "List all passwords in your vault.",
Aliases: []string{"."},
RunE: func(cmd *cobra.Command, args []string) error {
if err := tea.NewProgram(lister.Lister(), tea.WithAltScreen()).Start(); err != nil {
fmt.Printf("could not start program: %s\n", err)
os.Exit(1)
if PwOpts.ShowTreeView {
st := shared.DefaultStyles()

s := spinner.New(spinner.CharSets[11], 100 * time.Millisecond)
s.Suffix = " 📡 Preparing & Getting data..."
s.Start()

err, out, errout := gosh.RunOutput("scc . -t")

s.Stop()

if err != nil {
if strings.Contains(errout, "401") || strings.Contains(out, "401") {
head := st.Error.Render("\n\nYour Authentication is Expired.")
body := st.Subtle.Render(" Refresh your authentication via `secman auth refresh`.")

fmt.Println(lipgloss.NewStyle().PaddingLeft(2).SetString(constants.Logo("Secman Lister") + st.Wrap.Render(head + body)).String())

os.Exit(0)
}

fmt.Println(errout)
}

fmt.Print(lipgloss.NewStyle().PaddingLeft(2).SetString(constants.Logo("Secman Lister") + "\n\n" + st.Wrap.Render(out)).String())
} else {
if err := tea.NewProgram(lister.Lister(), tea.WithAltScreen()).Start(); err != nil {
fmt.Printf("could not start program: %s\n", err)
os.Exit(1)
}
}

return nil
},
}

cmd.Flags().BoolVarP(&PwOpts.ShowTreeView, "tree-view", "t", false, "List passwords in tree view.")

return cmd
}
1 change: 1 addition & 0 deletions app/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var PwOpts = options.PasswordsOptions{
Servers: false,
ShowHidden: false,
ShowJsonView: false,
ShowTreeView: false,
}

var GenOpts = options.GenOptions{
Expand Down
Loading

0 comments on commit 685c19b

Please sign in to comment.