Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ pman is a command line tool to keep track of all your side projects.
## Why?
I needed something to keep track of all my side projects.

## Install using the go package manager

```
go get github.com/theredditbandit/pman@latest
```

## Usage

```
Expand Down
2 changes: 1 addition & 1 deletion cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var infoCmd = &cobra.Command{
glamour.WithWordWrap(120),
glamour.WithAutoStyle(),
)
out, err := r.Render(string(infoData))
out, _ := r.Render(string(infoData))
fmt.Print(out)
},
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/ui/statusTable.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ func RenderTable(data map[string]string) error {
var TableData [][]string
for p, status := range data {
alias, err := db.GetRecord(p, pkg.ProjectAliasBucket)
lastEdited := pkg.GetLastModifiedTime(p)
if err == nil {
pname := fmt.Sprintf("%s (%s)", p, alias)
row := []string{pkg.TitleCase(status), pname} // Status | prjectName (alias)
row := []string{pkg.TitleCase(status), pname, lastEdited} // Status | prjectName (alias)
TableData = append(TableData, row)
} else {
row := []string{pkg.TitleCase(status), p} // Status | prjectName
row := []string{pkg.TitleCase(status), p, lastEdited} // Status | prjectName
TableData = append(TableData, row)
}
}
Expand All @@ -44,12 +45,12 @@ func RenderTable(data map[string]string) error {
"Aborted": lipgloss.Color("#FF875F"),
"Default": lipgloss.Color("#929292"),
}
headers := []string{"Project Name", "Status"}
headers := []string{"Project Name", "Status", "Last Edited"}
t := table.New().
Border(lipgloss.NormalBorder()).
BorderStyle(re.NewStyle().Foreground(lipgloss.Color("238"))).
Headers(headers...).
Width(80).
Width(100).
Rows(TableData...).
StyleFunc(func(row, col int) lipgloss.Style {
if row == 0 {
Expand Down
35 changes: 35 additions & 0 deletions pkg/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package pkg

import (
"fmt"
"os"
"path/filepath"
"time"

"github.com/theredditbandit/pman/pkg/db"
"golang.org/x/text/cases"
"golang.org/x/text/language"
Expand Down Expand Up @@ -33,3 +37,34 @@ func PrintData(data map[string]string) {
}
}
}

func GetLastModifiedTime(pname string) string {
var lastModTime time.Time
var lastModFile string
today := time.Now()
_ = lastModFile
pPath, err := db.GetRecord(pname, ProjectPaths)
if err != nil {
return "Something went wrong"
}
err = filepath.Walk(pPath, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() && info.ModTime().After(lastModTime) {
lastModTime = info.ModTime()
lastModFile = info.Name()
}
return nil
})
if err != nil {
return "Something went wrong"
}
switch fmt.Sprint(lastModTime.Date()) {
case fmt.Sprint(today.Date()):
return "Today"
case fmt.Sprint(today.AddDate(0, 0, -1).Date()):
return "Yesterday"
}
return fmt.Sprint(lastModTime.Date())
}