Skip to content

Commit d57b505

Browse files
authored
Merge pull request #5 from theredditbandit/pman-tui
Pman tui
2 parents 3b1d04b + 60bc9f9 commit d57b505

File tree

4 files changed

+47
-5
lines changed

4 files changed

+47
-5
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ pman is a command line tool to keep track of all your side projects.
55
## Why?
66
I needed something to keep track of all my side projects.
77

8+
## Install using the go package manager
9+
10+
```
11+
go get github.com/theredditbandit/pman@latest
12+
```
13+
814
## Usage
915

1016
```

cmd/info.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var infoCmd = &cobra.Command{
3838
glamour.WithWordWrap(120),
3939
glamour.WithAutoStyle(),
4040
)
41-
out, err := r.Render(string(infoData))
41+
out, _ := r.Render(string(infoData))
4242
fmt.Print(out)
4343
},
4444
}

pkg/ui/statusTable.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ func RenderTable(data map[string]string) error {
1515
var TableData [][]string
1616
for p, status := range data {
1717
alias, err := db.GetRecord(p, pkg.ProjectAliasBucket)
18+
lastEdited := pkg.GetLastModifiedTime(p)
1819
if err == nil {
1920
pname := fmt.Sprintf("%s (%s)", p, alias)
20-
row := []string{pkg.TitleCase(status), pname} // Status | prjectName (alias)
21+
row := []string{pkg.TitleCase(status), pname, lastEdited} // Status | prjectName (alias)
2122
TableData = append(TableData, row)
2223
} else {
23-
row := []string{pkg.TitleCase(status), p} // Status | prjectName
24+
row := []string{pkg.TitleCase(status), p, lastEdited} // Status | prjectName
2425
TableData = append(TableData, row)
2526
}
2627
}
@@ -44,12 +45,12 @@ func RenderTable(data map[string]string) error {
4445
"Aborted": lipgloss.Color("#FF875F"),
4546
"Default": lipgloss.Color("#929292"),
4647
}
47-
headers := []string{"Project Name", "Status"}
48+
headers := []string{"Project Name", "Status", "Last Edited"}
4849
t := table.New().
4950
Border(lipgloss.NormalBorder()).
5051
BorderStyle(re.NewStyle().Foreground(lipgloss.Color("238"))).
5152
Headers(headers...).
52-
Width(80).
53+
Width(100).
5354
Rows(TableData...).
5455
StyleFunc(func(row, col int) lipgloss.Style {
5556
if row == 0 {

pkg/utils.go

+35
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ package pkg
22

33
import (
44
"fmt"
5+
"os"
6+
"path/filepath"
7+
"time"
8+
59
"github.com/theredditbandit/pman/pkg/db"
610
"golang.org/x/text/cases"
711
"golang.org/x/text/language"
@@ -33,3 +37,34 @@ func PrintData(data map[string]string) {
3337
}
3438
}
3539
}
40+
41+
func GetLastModifiedTime(pname string) string {
42+
var lastModTime time.Time
43+
var lastModFile string
44+
today := time.Now()
45+
_ = lastModFile
46+
pPath, err := db.GetRecord(pname, ProjectPaths)
47+
if err != nil {
48+
return "Something went wrong"
49+
}
50+
err = filepath.Walk(pPath, func(path string, info os.FileInfo, err error) error {
51+
if err != nil {
52+
return err
53+
}
54+
if !info.IsDir() && info.ModTime().After(lastModTime) {
55+
lastModTime = info.ModTime()
56+
lastModFile = info.Name()
57+
}
58+
return nil
59+
})
60+
if err != nil {
61+
return "Something went wrong"
62+
}
63+
switch fmt.Sprint(lastModTime.Date()) {
64+
case fmt.Sprint(today.Date()):
65+
return "Today"
66+
case fmt.Sprint(today.AddDate(0, 0, -1).Date()):
67+
return "Yesterday"
68+
}
69+
return fmt.Sprint(lastModTime.Date())
70+
}

0 commit comments

Comments
 (0)