Skip to content

Commit 7df80f0

Browse files
committed
feat(cli): incident info --num + channel team/creator names (fc-event#1674)
Propagate fc-event#1674 through the generated layer by bumping go-flashduty to the synced+regenerated spec, plus a cligen enhancement so the now-optional incident_id stays back-compatible: - incident info: new --num flag (server-side 6-char short-id lookup); incident_id relaxed to optional. Add an OPTIONAL positional mode to cligen (optionalArg + positional.Optional + optionalPositional map) so `incident info <id>` keeps working while `incident info --num CBE249` resolves and bare `incident info` (with --num) is valid; `incident info a b` still rejected. - channel list/info: response help documents team_name + creator_name. go-flashduty pinned to the chore/enrich-1674-spec commit (pseudo-version); re-pin to the released version after go-flashduty#11 merges. Build + unit tests (incl. gen_positional) pass.
1 parent e6a8fa2 commit 7df80f0

8 files changed

Lines changed: 83 additions & 23 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/flashcatcloud/flashduty-cli
33
go 1.25.1
44

55
require (
6-
github.com/flashcatcloud/go-flashduty v0.5.4-0.20260602051355-7583ebae5b07
6+
github.com/flashcatcloud/go-flashduty v0.5.4-0.20260616041609-da82c4097dd1
77
github.com/mattn/go-runewidth v0.0.24
88
github.com/spf13/cobra v1.10.2
99
github.com/spf13/pflag v1.0.10

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
github.com/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY=
22
github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
33
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
4-
github.com/flashcatcloud/go-flashduty v0.5.4-0.20260602051355-7583ebae5b07 h1:bi1rOjR2OY+TovBGabtVOTcEQWlgzU9RfEwlJxU+3n8=
5-
github.com/flashcatcloud/go-flashduty v0.5.4-0.20260602051355-7583ebae5b07/go.mod h1:aA0RtZEs0AYOwwdNKdtVeD8YMOdnmVY1zAlVD+9Ovx8=
4+
github.com/flashcatcloud/go-flashduty v0.5.4-0.20260616041609-da82c4097dd1 h1:K/TceO2NHUPAB8Ew7p/7y6gGDjokNpHyd30uxi8FApc=
5+
github.com/flashcatcloud/go-flashduty v0.5.4-0.20260616041609-da82c4097dd1/go.mod h1:aA0RtZEs0AYOwwdNKdtVeD8YMOdnmVY1zAlVD+9Ovx8=
66
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
77
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
88
github.com/mattn/go-runewidth v0.0.24 h1:cpokDiIn0MGnhdHwuWnJBITySJ20QyNGnY2kR/ay2DU=

internal/cli/args.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ func requireExactArg(name string) cobra.PositionalArgs {
4141
}
4242
}
4343

44+
// optionalArg returns a positional argument validator that accepts zero or one
45+
// argument named name. It backs generated commands whose positional folds into
46+
// an OPTIONAL body field because the operation also accepts an alternative
47+
// lookup key via a flag (e.g. `incident info` takes either the <incident-id>
48+
// positional or --num). Extra arguments are rejected rather than silently
49+
// dropped:
50+
//
51+
// - zero or one arg: ok
52+
// - >1 args: "expects at most one <name>. Usage: ..."
53+
func optionalArg(name string) cobra.PositionalArgs {
54+
return func(cmd *cobra.Command, args []string) error {
55+
if len(args) > 1 {
56+
return fmt.Errorf("expects at most one %s. Usage: %s", name, cmd.UseLine())
57+
}
58+
return nil
59+
}
60+
}
61+
4462
// requireExactlyOneFlag validates that exactly one of the named flags is set.
4563
func requireExactlyOneFlag(cmd *cobra.Command, flagNames ...string) error {
4664
set := 0

internal/cli/gen_positional_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,26 @@ func TestGenPositionalUseLine(t *testing.T) {
2929
t.Errorf("ack twin Args rejected one arg: %v", err)
3030
}
3131

32+
// `incident info` pins incident_id as an OPTIONAL positional: the backend
33+
// relaxed incident_id (a lookup may instead pass the 6-char num via --num), so
34+
// the positional is 0-or-1. `info <id>` stays for back-compat; `info` alone
35+
// (with --num) is valid; `info id1 id2` is still rejected.
3236
info := genIncidentsInfoCmd()
33-
if got := info.Use; got != "info <incident-id>" {
34-
t.Errorf("info twin Use = %q, want %q", got, "info <incident-id>")
37+
if got := info.Use; got != "info [<incident-id>]" {
38+
t.Errorf("info twin Use = %q, want %q", got, "info [<incident-id>]")
3539
}
3640
if info.Args == nil {
3741
t.Errorf("info twin has no Args validator")
3842
}
39-
if err := info.Args(info, nil); err == nil {
40-
t.Errorf("info twin Args accepted zero args (want exactly one)")
43+
if err := info.Args(info, nil); err != nil {
44+
t.Errorf("info twin Args rejected zero args (want 0-or-1; --num path): %v", err)
4145
}
4246
if err := info.Args(info, []string{"id1"}); err != nil {
4347
t.Errorf("info twin Args rejected one arg: %v", err)
4448
}
49+
if err := info.Args(info, []string{"id1", "id2"}); err == nil {
50+
t.Errorf("info twin Args accepted two args (want at most one)")
51+
}
4552

4653
// Override cases: merge pins target_incident_id (NOT source_incident_ids);
4754
// war-room detail pins chat_id.

internal/cli/zz_generated_channels.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cli/zz_generated_incidents.go

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)