Skip to content

Commit d84e473

Browse files
feat: Add --limit flag to list command
1 parent 9baf3e5 commit d84e473

File tree

6 files changed

+373
-2
lines changed

6 files changed

+373
-2
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
- Use `mise` for all build, test, etc. commands.
55
- Always run `mise run check` when you're done.
66
- Use `mint` for all task tracking and issue management. Run `mint -h` to see all available commands.
7+
- Use `jj`, not `git`, for all git commands.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ READY
9292
mint-j0 open Add initial code structure
9393
```
9494

95+
```bash
96+
→ mint list --limit 1
97+
READY (1 of 2)
98+
99+
mint-j0 open Add initial code structure
100+
101+
BLOCKED (1 of 1)
102+
103+
mint-a8 open Support closing issues
104+
105+
CLOSED (1 of 1)
106+
107+
mint-8G closed Write tests for closing issues
108+
```
109+
95110
```bash
96111
→ mint update mint-a8 --comment "The problem is in main.go:123."
97112
Added a comment to issue mint-a8 with text "The problem is in main.go:123."

cli.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func newCommand() *cli.Command {
6666
Name: "ready",
6767
Usage: "Only show ready issues",
6868
},
69+
&cli.IntFlag{
70+
Name: "limit",
71+
Usage: "Limit the number of issues shown per section",
72+
},
6973
},
7074
Action: listAction,
7175
},

cmd_list.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func listAction(_ context.Context, cmd *cli.Command) error {
5858

5959
openOnly := cmd.Bool("open")
6060
readyOnly := cmd.Bool("ready")
61+
limit := cmd.Int("limit")
6162

6263
// Sort issues by timestamps (only what we'll display)
6364
sortByCreatedAt(readyIssues)
@@ -68,11 +69,33 @@ func listAction(_ context.Context, cmd *cli.Command) error {
6869
sortByUpdatedAt(closedIssues)
6970
}
7071

72+
// Track original counts before applying limit
73+
readyTotalCount := len(readyIssues)
74+
blockedTotalCount := len(blockedIssues)
75+
closedTotalCount := len(closedIssues)
76+
77+
// Apply limit to each section (if limit > 0)
78+
if limit > 0 {
79+
if len(readyIssues) > limit {
80+
readyIssues = readyIssues[:limit]
81+
}
82+
if len(blockedIssues) > limit {
83+
blockedIssues = blockedIssues[:limit]
84+
}
85+
if len(closedIssues) > limit {
86+
closedIssues = closedIssues[:limit]
87+
}
88+
}
89+
7190
// Display READY section
7291
if _, err := fmt.Fprintln(w); err != nil {
7392
return err
7493
}
7594
readyHeader := "\033[48;5;2m\033[38;5;0m READY \033[0m"
95+
// Add limit indicator if section is actually limited
96+
if limit > 0 && len(readyIssues) < readyTotalCount {
97+
readyHeader += fmt.Sprintf(" \033[38;5;8m(%d of %d)\033[0m", len(readyIssues), readyTotalCount)
98+
}
7699
if _, err := fmt.Fprintln(w, readyHeader); err != nil {
77100
return err
78101
}
@@ -97,6 +120,10 @@ func listAction(_ context.Context, cmd *cli.Command) error {
97120
}
98121

99122
blockedHeader := "\033[48;5;1m\033[38;5;0m BLOCKED \033[0m"
123+
// Add limit indicator if section is actually limited
124+
if limit > 0 && len(blockedIssues) < blockedTotalCount {
125+
blockedHeader += fmt.Sprintf(" \033[38;5;8m(%d of %d)\033[0m", len(blockedIssues), blockedTotalCount)
126+
}
100127
if _, err := fmt.Fprintln(w, blockedHeader); err != nil {
101128
return err
102129
}
@@ -122,6 +149,10 @@ func listAction(_ context.Context, cmd *cli.Command) error {
122149
}
123150

124151
closedHeader := "\033[48;5;0m\033[38;5;15m CLOSED \033[0m"
152+
// Add limit indicator if section is actually limited
153+
if limit > 0 && len(closedIssues) < closedTotalCount {
154+
closedHeader += fmt.Sprintf(" \033[38;5;8m(%d of %d)\033[0m", len(closedIssues), closedTotalCount)
155+
}
125156
if _, err := fmt.Fprintln(w, closedHeader); err != nil {
126157
return err
127158
}

0 commit comments

Comments
 (0)