Skip to content

Commit

Permalink
replace the old pman interactive ui with a more minimalist one (#40)
Browse files Browse the repository at this point in the history
this removes the need to specify pman ls --c as that is now the default pman ls behaviour
  • Loading branch information
theredditbandit authored May 21, 2024
1 parent 90ffcb3 commit 1c3366d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 287 deletions.
21 changes: 19 additions & 2 deletions cmd/i.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
package cmd

import (
"fmt"
"strings"

"github.com/spf13/cobra"

"github.com/theredditbandit/pman/pkg/db"
"github.com/theredditbandit/pman/pkg/ui"
"github.com/theredditbandit/pman/pkg/utils"
)

// iCmd represents the interactive command
var iCmd = &cobra.Command{
Use: "i",
Short: "Launches pman in interactive mode",
Aliases: []string{"interactive", "iteractive"},
RunE: func(_ *cobra.Command, _ []string) error {
return ui.Tui()
RunE: func(cmd *cobra.Command, _ []string) error {
filterFlag, _ := cmd.Flags().GetString("f")
refreshLastEditTime, _ := cmd.Flags().GetBool("r")
data, err := db.GetAllRecords(db.DBName, StatusBucket)
if err != nil {
return err
}
if filterFlag != "" {
fmt.Println("Filtering by status : ", filterFlag)
data = utils.FilterByStatuses(data, strings.Split(filterFlag, ","))
}
return ui.RenderInteractiveTable(data, refreshLastEditTime)
},
}

func init() {
rootCmd.AddCommand(iCmd)
iCmd.Flags().String("f", "", "Filter projects by status. Usage : pman ls --f <status1[,status2]>")
iCmd.Flags().Bool("r", false, "Refresh Last Edited time: pman ls --r")
}
7 changes: 1 addition & 6 deletions cmd/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var lsCmd = &cobra.Command{
`,
RunE: func(cmd *cobra.Command, _ []string) error {
filterFlag, _ := cmd.Flags().GetString("f")
oldUI, _ := cmd.Flags().GetBool("c")
refreshLastEditTime, _ := cmd.Flags().GetBool("r")
data, err := db.GetAllRecords(db.DBName, StatusBucket)
if err != nil {
Expand All @@ -29,16 +28,12 @@ var lsCmd = &cobra.Command{
fmt.Println("Filtering by status : ", filterFlag)
data = utils.FilterByStatuses(data, strings.Split(filterFlag, ","))
}
if oldUI {
return ui.RenderTable(data, refreshLastEditTime)
}
return ui.RenderInteractiveTable(data, refreshLastEditTime)
return ui.RenderTable(data, refreshLastEditTime)
},
}

func init() {
rootCmd.AddCommand(lsCmd)
lsCmd.Flags().String("f", "", "Filter projects by status. Usage : pman ls --f <status1[,status2]>")
lsCmd.Flags().Bool("c", false, "list projects using the colorful table. Usage : pman ls --c")
lsCmd.Flags().Bool("r", false, "Refresh Last Edited time: pman ls --r")
}
87 changes: 0 additions & 87 deletions pkg/ui/delegate.go

This file was deleted.

192 changes: 0 additions & 192 deletions pkg/ui/tui.go

This file was deleted.

0 comments on commit 1c3366d

Please sign in to comment.