From 9f5d6972b8ff4d49eaa2db9b9d5f5e7a8e5b11fa Mon Sep 17 00:00:00 2001 From: aryan <85390033+theredditbandit@users.noreply.github.com> Date: Tue, 7 May 2024 23:51:19 +0530 Subject: [PATCH 1/2] rebase from master --- cmd/ls.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/ls.go b/cmd/ls.go index d61634d..bc4aa0f 100644 --- a/cmd/ls.go +++ b/cmd/ls.go @@ -37,5 +37,5 @@ var lsCmd = &cobra.Command{ func init() { rootCmd.AddCommand(lsCmd) lsCmd.Flags().String("f", "", "Filter projects by status. Usage : pman ls --f ") - lsCmd.Flags().Bool("o", false, "list projects using the old ui. Usage : pman ls --o") + lsCmd.Flags().Bool("c", false, "list projects using the colorful table. Usage : pman ls --c") } From dcb1cefee760b6bb7cb45bb4bb1f93d973af0fdf Mon Sep 17 00:00:00 2001 From: aryan <85390033+theredditbandit@users.noreply.github.com> Date: Thu, 16 May 2024 00:32:04 +0530 Subject: [PATCH 2/2] bugfix: fix bug in ReadREADME function --- cmd/ls.go | 2 +- pkg/ui/interactiveTable.go | 9 +++++++-- pkg/utils/utils.go | 17 +++++++++++------ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/cmd/ls.go b/cmd/ls.go index bc4aa0f..7dc2644 100644 --- a/cmd/ls.go +++ b/cmd/ls.go @@ -18,7 +18,7 @@ var lsCmd = &cobra.Command{ `, RunE: func(cmd *cobra.Command, _ []string) error { filterFlag, _ := cmd.Flags().GetString("f") - oldUI, _ := cmd.Flags().GetBool("o") + oldUI, _ := cmd.Flags().GetBool("c") data, err := db.GetAllRecords(db.DBName, StatusBucket) if err != nil { return err diff --git a/pkg/ui/interactiveTable.go b/pkg/ui/interactiveTable.go index 86fc82c..5e941d3 100644 --- a/pkg/ui/interactiveTable.go +++ b/pkg/ui/interactiveTable.go @@ -3,6 +3,7 @@ package ui import ( "fmt" "sort" + "strings" "github.com/charmbracelet/bubbles/table" tea "github.com/charmbracelet/bubbletea" @@ -10,7 +11,7 @@ import ( "github.com/theredditbandit/pman/pkg" "github.com/theredditbandit/pman/pkg/db" - p "github.com/theredditbandit/pman/pkg/ui/pager" + pgr "github.com/theredditbandit/pman/pkg/ui/pager" "github.com/theredditbandit/pman/pkg/utils" ) @@ -38,7 +39,11 @@ func (m tableModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, tea.Quit case "enter": project := m.table.SelectedRow()[1] - err := p.LaunchRenderer(project) + if strings.Contains(project, ")") { // project is of the form a-long-project-name (alias) + projectAliasArr := strings.Split(project, " ") + project = projectAliasArr[0] + } + err := pgr.LaunchRenderer(project) if err != nil { return m, tea.Quit } diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index ddca814..670afdf 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -96,14 +96,19 @@ func BeautifyMD(data []byte) (string, error) { // ReadREADME: returns the byte array of README.md of a project func ReadREADME(projectName string) ([]byte, error) { - actualName, err := db.GetRecord(db.DBName, projectName, pkg.ProjectAliasBucket) - if err == nil { - projectName = actualName - } path, err := db.GetRecord(db.DBName, projectName, pkg.ProjectPaths) if err != nil { - log.Printf("project: %v not a valid project\n", projectName) - return nil, errors.Join(ErrReadREADME, err) + actualName, err := db.GetRecord(db.DBName, projectName, pkg.ProjectAliasBucket) + if err != nil { + log.Printf("project: %v not a valid project\n", projectName) + return nil, errors.Join(ErrReadREADME, err) + } + projectName = actualName + path, err = db.GetRecord(db.DBName, projectName, pkg.ProjectPaths) + if err != nil { + log.Printf("project: %v not a valid project\n", projectName) + return nil, errors.Join(ErrReadREADME, err) + } } pPath := filepath.Join(path, "README.md") data, err := os.ReadFile(pPath)