Skip to content

Commit 18098ae

Browse files
committed
fix(cli): address review findings — conflict detection, polish
- team get: error when positional <id> and any named flag are both provided (previously silently discarded the flag); add test for the conflict case - Restore member-resolution comment explaining the second round-trip - insight Short: trim to 63 chars (was 104, longest in codebase) - incident list Long: use <team|responder|channel> metavar instead of bare pipe to avoid shell-alternation confusion
1 parent 8bb1148 commit 18098ae

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

internal/cli/incident.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func newIncidentListCmd() *cobra.Command {
8080
cmd := &cobra.Command{
8181
Use: "list",
8282
Short: "List incidents",
83-
Long: curatedLong("List incidents matching the given filters. The --since/--until window must be < 31 days; --limit max is 100.\n\nSee also: fduty insight team|responder|channel for aggregated metrics (MTTA, MTTR, noise reduction) instead of paginating raw incidents.", "Incidents", "List"),
83+
Long: curatedLong("List incidents matching the given filters. The --since/--until window must be < 31 days; --limit max is 100.\n\nSee also: fduty insight <team|responder|channel> for aggregated metrics (MTTA, MTTR, noise reduction) instead of paginating raw incidents.", "Incidents", "List"),
8484
RunE: func(cmd *cobra.Command, args []string) error {
8585
return runCommand(cmd, args, func(ctx *RunContext) error {
8686
startTime, err := timeutil.Parse(since)

internal/cli/insight.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
func newInsightCmd() *cobra.Command {
1414
cmd := &cobra.Command{
1515
Use: "insight",
16-
Short: "Query aggregated incident metrics by team/responder/channel (preferred over incident list for analytics)",
16+
Short: "Query aggregated incident metrics by team, responder, or channel",
1717
}
1818
// insight team/channel/responder are now served by the generated commands
1919
// (richer flag set: severities, *_ids, fields, aggregate-unit, …; relative

internal/cli/team.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ Examples:
108108
Args: optionalArg("id"),
109109
PreRunE: func(cmd *cobra.Command, args []string) error {
110110
if len(args) == 1 {
111+
for _, f := range []string{"id", "name", "ref-id"} {
112+
if cmd.Flags().Changed(f) {
113+
return fmt.Errorf("positional <id> cannot be combined with --%s", f)
114+
}
115+
}
111116
return nil
112117
}
113118
return requireExactlyOneFlag(cmd, "id", "name", "ref-id")
@@ -134,6 +139,8 @@ Examples:
134139
return ctx.Printer.Print(team, nil)
135140
}
136141

142+
// TeamItem carries only member person IDs; resolve names/emails
143+
// in one batch to replicate the legacy member display.
137144
members := resolveTeamMemberInfos(ctx, team.PersonIDs)
138145
printTeamDetail(ctx.Writer, team, members)
139146
return nil

internal/cli/team_get_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@ func TestTeamGetPositionalArgBypassesPreRunE(t *testing.T) {
2727
t.Fatalf("PreRunE should succeed with positional arg, got: %v", err)
2828
}
2929
}
30+
31+
func TestTeamGetPositionalAndFlagConflictFails(t *testing.T) {
32+
cmd := newTeamGetCmd()
33+
_ = cmd.Flags().Set("id", "456")
34+
err := cmd.PreRunE(cmd, []string{"123"})
35+
if err == nil {
36+
t.Fatal("expected error when positional arg and --id flag are both provided")
37+
}
38+
}

0 commit comments

Comments
 (0)