Skip to content

Commit c32f4eb

Browse files
authored
fix(member): add --limit flag to member list + page/limit consistency test (#42)
* fix(member): add --limit flag to member list and enforce page/limit pairing member list registered --page but not --limit even though the SDK's MemberListRequest embeds ListOptions with a Limit field, so agents that learned --limit on other list commands got 'unknown flag: --limit'. Add the flag (same wording/default as team list) and a cobra-tree test asserting any command with --page also exposes --limit. * fix(member): add --orderby and --asc flags to member list MemberListRequest already exposes Orderby and Asc fields (generated from the OpenAPI schema); team list has both flags with identical wording and defaults. Wire them to close the sibling-parameter gap found during the audit-2026-06-11b param consistency review.
1 parent e2f155d commit c32f4eb

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package cli
2+
3+
import (
4+
"testing"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
// TestPageImpliesLimit walks the full command tree and asserts that any
10+
// command exposing a --page flag also exposes --limit. Agents transfer flag
11+
// knowledge across command groups; a paginated list without --limit forces
12+
// trial-and-error round-trips (seen in prod: `member list --limit` failing
13+
// with "unknown flag").
14+
func TestPageImpliesLimit(t *testing.T) {
15+
var walk func(cmd *cobra.Command)
16+
walk = func(cmd *cobra.Command) {
17+
if cmd.Flags().Lookup("page") != nil && cmd.Flags().Lookup("limit") == nil {
18+
t.Errorf("%s registers --page but not --limit", cmd.CommandPath())
19+
}
20+
for _, sub := range cmd.Commands() {
21+
walk(sub)
22+
}
23+
}
24+
walk(rootCmd)
25+
}

internal/cli/member.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ func newMemberCmd() *cobra.Command {
2222
func newMemberListCmd() *cobra.Command {
2323
var name, email string
2424
var page int
25+
var limit int
2526
var roleID int64
27+
var orderBy string
28+
var asc bool
2629

2730
cmd := &cobra.Command{
2831
Use: "list",
@@ -39,9 +42,12 @@ func newMemberListCmd() *cobra.Command {
3942
query = email
4043
}
4144
req := &flashduty.MemberListRequest{
42-
Query: query,
45+
Query: query,
46+
Orderby: orderBy,
47+
Asc: asc,
4348
}
4449
req.Page = page
50+
req.Limit = limit
4551
if roleID != 0 {
4652
req.RoleID = uint64(roleID)
4753
}
@@ -83,6 +89,9 @@ func newMemberListCmd() *cobra.Command {
8389
cmd.Flags().StringVar(&name, "name", "", "Search by name")
8490
cmd.Flags().StringVar(&email, "email", "", "Search by email")
8591
cmd.Flags().IntVar(&page, "page", 1, "Page number")
92+
cmd.Flags().IntVar(&limit, "limit", 20, "Page size, max 100 (default 20)")
93+
cmd.Flags().StringVar(&orderBy, "orderby", "", "Sort field: created_at, updated_at, member_name")
94+
cmd.Flags().BoolVar(&asc, "asc", false, "Sort in ascending order")
8695
cmd.Flags().Int64Var(&roleID, "role-id", 0, "Filter to members holding this role ID")
8796

8897
return cmd

0 commit comments

Comments
 (0)