bots-garden/mini-mepublic Fork
⑂ 951bd25
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/mini-me.git
git clone ssh://git@rickub.com/bots-garden/mini-me.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

Merge feature/mm-help into main

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agent committed 2026-11-26T22:53:52+01:00 Browse files
951bd25 parents: f4b8126 1388ba2
modified .tickets/issues/0273-mm-help-an-overview-of-mm-and-its-subcommands.yaml +25 -7
@@ -1,12 +1,13 @@
11 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
22 id: 273
33 title: "mm help: the same as mm --help and mm -help"
4-state: open
4+state: closed
55 author:
66 name: k33g
77 email: ph.charriere@gmail.com
88 createdAt: 2026-11-27T07:30:00.000Z
9-updatedAt: 2026-11-27T07:45:00.000Z
9+updatedAt: 2026-11-27T09:00:00.000Z
10+closedAt: 2026-11-27T09:00:00.000Z
1011 labels:
1112 - enhancement
1213 - kind::feature
@@ -83,20 +84,37 @@ tasks:
8384 closedAt: 2026-11-27T07:45:00.000Z
8485 - id: 2
8586 title: "mm help as the first argument = mm --help (same text, stderr, exit 0) — with a test comparing them"
86- state: open
87+ state: closed
8788 priority: medium
8889 author:
8990 name: k33g
9091 email: ph.charriere@gmail.com
9192 createdAt: 2026-11-27T07:45:00.000Z
92- updatedAt: 2026-11-27T07:45:00.000Z
93+ updatedAt: 2026-11-27T08:00:00.000Z
94+ closedAt: 2026-11-27T08:00:00.000Z
9395 - id: 3
9496 title: "Docs EN+FR: reference/cli.md"
95- state: open
97+ state: closed
9698 priority: low
9799 author:
98100 name: k33g
99101 email: ph.charriere@gmail.com
100102 createdAt: 2026-11-27T07:45:00.000Z
101- updatedAt: 2026-11-27T07:45:00.000Z
102-comments: []
103+ updatedAt: 2026-11-27T08:00:00.000Z
104+ closedAt: 2026-11-27T08:00:00.000Z
105+comments:
106+ - id: 1
107+ author:
108+ name: k33g
109+ email: ph.charriere@gmail.com
110+ createdAt: 2026-11-27T08:00:00.000Z
111+ body: |
112+ Done on branch feature/mm-help (not merged yet): main.go
113+ modeWordAsFlag turns a first argument `help` into `-help`, like `tui`,
114+ `acp` and `a2a` — the flag package then prints the very same usage.
115+ Only the FIRST argument: `mm agent.yaml help` is unchanged. Tests:
116+ TestModeWordAsFlag (+2 cases), TestHelpIsTheSameAsDashHelp (child
117+ process, a file called `help` in the directory: help, -help, -h give
118+ the same stderr as --help, empty stdout, exit 0). Live with the built
119+ binary: the three outputs identical (35 lines), exit 0. go test ./...,
120+ vet, gofmt clean. Docs EN+FR: reference/cli.md (invocation, -h row).
@@ -1,12 +1,13 @@
1 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.1 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2 id: 2732 id: 273
3 title: "mm help: the same as mm --help and mm -help"3 title: "mm help: the same as mm --help and mm -help"
4-state: open4+state: closed
5 author:5 author:
6 name: k33g6 name: k33g
7 email: ph.charriere@gmail.com7 email: ph.charriere@gmail.com
8 createdAt: 2026-11-27T07:30:00.000Z8 createdAt: 2026-11-27T07:30:00.000Z
9-updatedAt: 2026-11-27T07:45:00.000Z9+updatedAt: 2026-11-27T09:00:00.000Z
10+closedAt: 2026-11-27T09:00:00.000Z
10 labels:11 labels:
11 - enhancement12 - enhancement
12 - kind::feature13 - kind::feature
@@ -83,20 +84,37 @@ tasks:
83 closedAt: 2026-11-27T07:45:00.000Z84 closedAt: 2026-11-27T07:45:00.000Z
84 - id: 285 - id: 2
85 title: "mm help as the first argument = mm --help (same text, stderr, exit 0) — with a test comparing them"86 title: "mm help as the first argument = mm --help (same text, stderr, exit 0) — with a test comparing them"
86- state: open87+ state: closed
87 priority: medium88 priority: medium
88 author:89 author:
89 name: k33g90 name: k33g
90 email: ph.charriere@gmail.com91 email: ph.charriere@gmail.com
91 createdAt: 2026-11-27T07:45:00.000Z92 createdAt: 2026-11-27T07:45:00.000Z
92- updatedAt: 2026-11-27T07:45:00.000Z93+ updatedAt: 2026-11-27T08:00:00.000Z
94+ closedAt: 2026-11-27T08:00:00.000Z
93 - id: 395 - id: 3
94 title: "Docs EN+FR: reference/cli.md"96 title: "Docs EN+FR: reference/cli.md"
95- state: open97+ state: closed
96 priority: low98 priority: low
97 author:99 author:
98 name: k33g100 name: k33g
99 email: ph.charriere@gmail.com101 email: ph.charriere@gmail.com
100 createdAt: 2026-11-27T07:45:00.000Z102 createdAt: 2026-11-27T07:45:00.000Z
101- updatedAt: 2026-11-27T07:45:00.000Z103+ updatedAt: 2026-11-27T08:00:00.000Z
102-comments: []104+ closedAt: 2026-11-27T08:00:00.000Z
105+comments:
106+ - id: 1
107+ author:
108+ name: k33g
109+ email: ph.charriere@gmail.com
110+ createdAt: 2026-11-27T08:00:00.000Z
111+ body: |
112+ Done on branch feature/mm-help (not merged yet): main.go
113+ modeWordAsFlag turns a first argument `help` into `-help`, like `tui`,
114+ `acp` and `a2a` — the flag package then prints the very same usage.
115+ Only the FIRST argument: `mm agent.yaml help` is unchanged. Tests:
116+ TestModeWordAsFlag (+2 cases), TestHelpIsTheSameAsDashHelp (child
117+ process, a file called `help` in the directory: help, -help, -h give
118+ the same stderr as --help, empty stdout, exit 0). Live with the built
119+ binary: the three outputs identical (35 lines), exit 0. go test ./...,
120+ vet, gofmt clean. Docs EN+FR: reference/cli.md (invocation, -h row).
modified docs/en/reference/cli.md +2 -1
@@ -15,6 +15,7 @@ mm sbxinit [flags] (write a sbxenv.yam
1515 mm skillcreate [flags] (write a new skill with a wizard)
1616 mm tui [<path>] [flags] (same as mm -tui)
1717 mm acp [<path>] [flags] (same as mm -acp)
18+mm help (same as mm -h, mm -help, mm --help)
1819 ```
1920
2021 | Element | Type | Default | Description |
@@ -30,7 +31,7 @@ mm acp [<path>] [flags] (same as mm -acp)
3031 | `--about` | bool | `false` | Print what `mm` is — one screen: version, the three front ends, the tools, the model servers, where the project and the docs live — and exit, before the configuration is read. |
3132 | `--ask <agent>` | string | `""` | Ask the agent `<agent>` (a key of `mmConfigs`) one question and exit; see [Ask mode specifics](#ask-mode-specifics). Like `-p`, works with the config file before or after: `mm agent.yaml --ask lucy -p "…"` and `mm --ask lucy -p "…" agent.yaml` are both valid. |
3233 | `--ask-with-context <agent>` | string | `""` | Same, sending a conversation read from stdin before the question. |
33-| `-h` | — | — | Print the flag usage and exit. |
34+| `-h` | — | — | Print the flag usage and exit. Also written `-help`, `--help`, or `help` as the first argument (ticket 273): the same text, on stderr, exit code 0. |
3435
3536 ## Version
3637
@@ -15,6 +15,7 @@ mm sbxinit [flags] (write a sbxenv.yam
15 mm skillcreate [flags] (write a new skill with a wizard)15 mm skillcreate [flags] (write a new skill with a wizard)
16 mm tui [<path>] [flags] (same as mm -tui)16 mm tui [<path>] [flags] (same as mm -tui)
17 mm acp [<path>] [flags] (same as mm -acp)17 mm acp [<path>] [flags] (same as mm -acp)
18+mm help (same as mm -h, mm -help, mm --help)
18 ```19 ```
19 20
20 | Element | Type | Default | Description |21 | Element | Type | Default | Description |
@@ -30,7 +31,7 @@ mm acp [<path>] [flags] (same as mm -acp)
30 | `--about` | bool | `false` | Print what `mm` is — one screen: version, the three front ends, the tools, the model servers, where the project and the docs live — and exit, before the configuration is read. |31 | `--about` | bool | `false` | Print what `mm` is — one screen: version, the three front ends, the tools, the model servers, where the project and the docs live — and exit, before the configuration is read. |
31 | `--ask <agent>` | string | `""` | Ask the agent `<agent>` (a key of `mmConfigs`) one question and exit; see [Ask mode specifics](#ask-mode-specifics). Like `-p`, works with the config file before or after: `mm agent.yaml --ask lucy -p "…"` and `mm --ask lucy -p "…" agent.yaml` are both valid. |32 | `--ask <agent>` | string | `""` | Ask the agent `<agent>` (a key of `mmConfigs`) one question and exit; see [Ask mode specifics](#ask-mode-specifics). Like `-p`, works with the config file before or after: `mm agent.yaml --ask lucy -p "…"` and `mm --ask lucy -p "…" agent.yaml` are both valid. |
32 | `--ask-with-context <agent>` | string | `""` | Same, sending a conversation read from stdin before the question. |33 | `--ask-with-context <agent>` | string | `""` | Same, sending a conversation read from stdin before the question. |
33-| `-h` | — | — | Print the flag usage and exit. |34+| `-h` | — | — | Print the flag usage and exit. Also written `-help`, `--help`, or `help` as the first argument (ticket 273): the same text, on stderr, exit code 0. |
34 35
35 ## Version36 ## Version
36 37
modified docs/fr/reference/cli.md +2 -1
@@ -15,6 +15,7 @@ mm sbxinit [options] (écrire un sbx
1515 mm skillcreate [options] (écrire un nouveau skill avec un assistant)
1616 mm tui [<chemin>] [options] (identique à mm -tui)
1717 mm acp [<chemin>] [options] (identique à mm -acp)
18+mm help (identique à mm -h, mm -help, mm --help)
1819 ```
1920
2021 | Élément | Type | Défaut | Description |
@@ -30,7 +31,7 @@ mm acp [<chemin>] [options] (identique à m
3031 | `--about` | bool | `false` | Affiche ce qu'est `mm` — un écran : version, les trois façades, les outils, les serveurs de modèles, où vivent le projet et la documentation — puis quitte, avant la lecture de la configuration. |
3132 | `--ask <agent>` | chaîne | `""` | Pose une question à l'agent `<agent>` (une clé de `mmConfigs`) et quitte ; voir [Spécificités du mode ask](#spécificités-du-mode-ask). Comme `-p`, fonctionne avec le fichier de configuration avant ou après : `mm agent.yaml --ask lucy -p "…"` et `mm --ask lucy -p "…" agent.yaml` sont tous deux valides. |
3233 | `--ask-with-context <agent>` | chaîne | `""` | Pareil, en envoyant avant la question une conversation lue sur stdin. |
33-| `-h` | — | — | Affiche l'usage des options et quitte. |
34+| `-h` | — | — | Affiche l'usage des options et quitte. S'écrit aussi `-help`, `--help`, ou `help` comme premier argument (ticket 273) : le même texte, sur stderr, code de sortie 0. |
3435
3536 ## Version
3637
@@ -15,6 +15,7 @@ mm sbxinit [options] (écrire un sbx
15 mm skillcreate [options] (écrire un nouveau skill avec un assistant)15 mm skillcreate [options] (écrire un nouveau skill avec un assistant)
16 mm tui [<chemin>] [options] (identique à mm -tui)16 mm tui [<chemin>] [options] (identique à mm -tui)
17 mm acp [<chemin>] [options] (identique à mm -acp)17 mm acp [<chemin>] [options] (identique à mm -acp)
18+mm help (identique à mm -h, mm -help, mm --help)
18 ```19 ```
19 20
20 | Élément | Type | Défaut | Description |21 | Élément | Type | Défaut | Description |
@@ -30,7 +31,7 @@ mm acp [<chemin>] [options] (identique à m
30 | `--about` | bool | `false` | Affiche ce qu'est `mm` — un écran : version, les trois façades, les outils, les serveurs de modèles, où vivent le projet et la documentation — puis quitte, avant la lecture de la configuration. |31 | `--about` | bool | `false` | Affiche ce qu'est `mm` — un écran : version, les trois façades, les outils, les serveurs de modèles, où vivent le projet et la documentation — puis quitte, avant la lecture de la configuration. |
31 | `--ask <agent>` | chaîne | `""` | Pose une question à l'agent `<agent>` (une clé de `mmConfigs`) et quitte ; voir [Spécificités du mode ask](#spécificités-du-mode-ask). Comme `-p`, fonctionne avec le fichier de configuration avant ou après : `mm agent.yaml --ask lucy -p "…"` et `mm --ask lucy -p "…" agent.yaml` sont tous deux valides. |32 | `--ask <agent>` | chaîne | `""` | Pose une question à l'agent `<agent>` (une clé de `mmConfigs`) et quitte ; voir [Spécificités du mode ask](#spécificités-du-mode-ask). Comme `-p`, fonctionne avec le fichier de configuration avant ou après : `mm agent.yaml --ask lucy -p "…"` et `mm --ask lucy -p "…" agent.yaml` sont tous deux valides. |
32 | `--ask-with-context <agent>` | chaîne | `""` | Pareil, en envoyant avant la question une conversation lue sur stdin. |33 | `--ask-with-context <agent>` | chaîne | `""` | Pareil, en envoyant avant la question une conversation lue sur stdin. |
33-| `-h` | — | — | Affiche l'usage des options et quitte. |34+| `-h` | — | — | Affiche l'usage des options et quitte. S'écrit aussi `-help`, `--help`, ou `help` comme premier argument (ticket 273) : le même texte, sur stderr, code de sortie 0. |
34 35
35 ## Version36 ## Version
36 37
modified init_assemble_test.go +2 -0
@@ -52,6 +52,8 @@ func TestModeWordAsFlag(t *testing.T) {
5252 {[]string{"mm", "agent.yaml", "tui"}, []string{"mm", "agent.yaml", "tui"}},
5353 {[]string{"mm", "./tui"}, []string{"mm", "./tui"}},
5454 {[]string{"mm"}, []string{"mm"}},
55+ {[]string{"mm", "help"}, []string{"mm", "-help"}},
56+ {[]string{"mm", "agent.yaml", "help"}, []string{"mm", "agent.yaml", "help"}},
5557 } {
5658 if got := modeWordAsFlag(c.in); !slices.Equal(got, c.want) {
5759 t.Errorf("modeWordAsFlag(%q) = %q, want %q", c.in, got, c.want)
@@ -52,6 +52,8 @@ func TestModeWordAsFlag(t *testing.T) {
52 {[]string{"mm", "agent.yaml", "tui"}, []string{"mm", "agent.yaml", "tui"}},52 {[]string{"mm", "agent.yaml", "tui"}, []string{"mm", "agent.yaml", "tui"}},
53 {[]string{"mm", "./tui"}, []string{"mm", "./tui"}},53 {[]string{"mm", "./tui"}, []string{"mm", "./tui"}},
54 {[]string{"mm"}, []string{"mm"}},54 {[]string{"mm"}, []string{"mm"}},
55+ {[]string{"mm", "help"}, []string{"mm", "-help"}},
56+ {[]string{"mm", "agent.yaml", "help"}, []string{"mm", "agent.yaml", "help"}},
55 } {57 } {
56 if got := modeWordAsFlag(c.in); !slices.Equal(got, c.want) {58 if got := modeWordAsFlag(c.in); !slices.Equal(got, c.want) {
57 t.Errorf("modeWordAsFlag(%q) = %q, want %q", c.in, got, c.want)59 t.Errorf("modeWordAsFlag(%q) = %q, want %q", c.in, got, c.want)
modified main.go +9 -4
@@ -110,7 +110,8 @@ func main() {
110110 os.Exit(skillcreate.Main(os.Args[2:], os.Stdin, os.Stdout, skillcreate.Options{Window: tui.RunSkillCreate, Terminal: tui.Terminal}))
111111 }
112112 // `mm tui` and `mm acp` (ticket 117): the modes as words too, like
113- // `mm init` — `mm tui agent.yaml` is `mm -tui agent.yaml`.
113+ // `mm init` — `mm tui agent.yaml` is `mm -tui agent.yaml`. `mm help`
114+ // (ticket 273) is `mm -help` the same way.
114115 os.Args = modeWordAsFlag(os.Args)
115116
116117 // Handle --prompt/-p flag which can appear after the config file argument
@@ -1030,15 +1031,19 @@ func isSbxInit(arg string) bool {
10301031 return arg == "sbxinit" || arg == "--sbxinit" || arg == "-sbxinit"
10311032 }
10321033
1033-// modeWordAsFlag turns a first argument `tui` or `acp` into its flag, so the
1034-// rest of main sees one spelling:
1034+// modeWordAsFlag turns a first argument `tui`, `acp`, `a2a` or `help` into
1035+// its flag, so the rest of main sees one spelling:
10351036 //
10361037 // modeWordAsFlag([]string{"mm", "tui", "agent.yaml"}) // → mm -tui agent.yaml
1038+// modeWordAsFlag([]string{"mm", "help"}) // → mm -help
1039+//
1040+// `mm help` (ticket 273) is exactly `mm -help`: the flag package prints the
1041+// same usage, on stderr, and exits 0.
10371042 //
10381043 // Only the first argument is a mode word: `mm agent.yaml tui` still names two
10391044 // config files, and a config file called tui is reached as ./tui.
10401045 func modeWordAsFlag(args []string) []string {
1041- if len(args) < 2 || (args[1] != "tui" && args[1] != "acp" && args[1] != "a2a") {
1046+ if len(args) < 2 || (args[1] != "tui" && args[1] != "acp" && args[1] != "a2a" && args[1] != "help") {
10421047 return args
10431048 }
10441049 return append([]string{args[0], "-" + args[1]}, args[2:]...)
@@ -110,7 +110,8 @@ func main() {
110 os.Exit(skillcreate.Main(os.Args[2:], os.Stdin, os.Stdout, skillcreate.Options{Window: tui.RunSkillCreate, Terminal: tui.Terminal}))110 os.Exit(skillcreate.Main(os.Args[2:], os.Stdin, os.Stdout, skillcreate.Options{Window: tui.RunSkillCreate, Terminal: tui.Terminal}))
111 }111 }
112 // `mm tui` and `mm acp` (ticket 117): the modes as words too, like112 // `mm tui` and `mm acp` (ticket 117): the modes as words too, like
113- // `mm init` — `mm tui agent.yaml` is `mm -tui agent.yaml`.113+ // `mm init` — `mm tui agent.yaml` is `mm -tui agent.yaml`. `mm help`
114+ // (ticket 273) is `mm -help` the same way.
114 os.Args = modeWordAsFlag(os.Args)115 os.Args = modeWordAsFlag(os.Args)
115 116
116 // Handle --prompt/-p flag which can appear after the config file argument117 // Handle --prompt/-p flag which can appear after the config file argument
@@ -1030,15 +1031,19 @@ func isSbxInit(arg string) bool {
1030 return arg == "sbxinit" || arg == "--sbxinit" || arg == "-sbxinit"1031 return arg == "sbxinit" || arg == "--sbxinit" || arg == "-sbxinit"
1031 }1032 }
1032 1033
1033-// modeWordAsFlag turns a first argument `tui` or `acp` into its flag, so the1034+// modeWordAsFlag turns a first argument `tui`, `acp`, `a2a` or `help` into
1034-// rest of main sees one spelling:1035+// its flag, so the rest of main sees one spelling:
1035 //1036 //
1036 // modeWordAsFlag([]string{"mm", "tui", "agent.yaml"}) // → mm -tui agent.yaml1037 // modeWordAsFlag([]string{"mm", "tui", "agent.yaml"}) // → mm -tui agent.yaml
1038+// modeWordAsFlag([]string{"mm", "help"}) // → mm -help
1039+//
1040+// `mm help` (ticket 273) is exactly `mm -help`: the flag package prints the
1041+// same usage, on stderr, and exits 0.
1037 //1042 //
1038 // Only the first argument is a mode word: `mm agent.yaml tui` still names two1043 // Only the first argument is a mode word: `mm agent.yaml tui` still names two
1039 // config files, and a config file called tui is reached as ./tui.1044 // config files, and a config file called tui is reached as ./tui.
1040 func modeWordAsFlag(args []string) []string {1045 func modeWordAsFlag(args []string) []string {
1041- if len(args) < 2 || (args[1] != "tui" && args[1] != "acp" && args[1] != "a2a") {1046+ if len(args) < 2 || (args[1] != "tui" && args[1] != "acp" && args[1] != "a2a" && args[1] != "help") {
1042 return args1047 return args
1043 }1048 }
1044 return append([]string{args[0], "-" + args[1]}, args[2:]...)1049 return append([]string{args[0], "-" + args[1]}, args[2:]...)
modified main_test.go +43 -0
@@ -5,6 +5,7 @@ import (
55 "errors"
66 "os"
77 "os/exec"
8+ "path/filepath"
89 "slices"
910 "strings"
1011 "testing"
@@ -100,3 +101,45 @@ func withoutEnv(names ...string) []string {
100101 }
101102 return out
102103 }
104+
105+// Ticket 273: `mm help` is exactly `mm --help` and `mm -help` — the same
106+// text on stderr, nothing on stdout, exit code 0 — even with a file called
107+// `help` in the directory. The real main runs in a child process, as above.
108+func TestHelpIsTheSameAsDashHelp(t *testing.T) {
109+ if os.Getenv("MM_TEST_RUN_MAIN") == "1" {
110+ os.Args = append([]string{"mm"}, strings.Fields(os.Getenv("MM_TEST_ARGS"))...)
111+ main()
112+ os.Exit(0)
113+ }
114+ dir := t.TempDir()
115+ if err := os.WriteFile(filepath.Join(dir, "help"), []byte("provider: dmr\nmodel: x\n"), 0o644); err != nil {
116+ t.Fatal(err)
117+ }
118+ run := func(args string) (string, string, int) {
119+ cmd := exec.Command(os.Args[0], "-test.run=^TestHelpIsTheSameAsDashHelp$")
120+ cmd.Dir = dir
121+ cmd.Env = append(withoutEnv("AGENT_CONFIG", "MM_CONFIG"), "MM_TEST_RUN_MAIN=1", "MM_TEST_ARGS="+args)
122+ var stdout, stderr bytes.Buffer
123+ cmd.Stdout, cmd.Stderr = &stdout, &stderr
124+ cmd.Stdin = strings.NewReader("")
125+ err := cmd.Run()
126+ code := 0
127+ var exit *exec.ExitError
128+ if errors.As(err, &exit) {
129+ code = exit.ExitCode()
130+ } else if err != nil {
131+ t.Fatal(err)
132+ }
133+ return stdout.String(), stderr.String(), code
134+ }
135+ _, want, wantCode := run("--help")
136+ if wantCode != 0 || !strings.Contains(want, "Usage of ") || !strings.Contains(want, "-version") {
137+ t.Fatalf("mm --help: exit %d, stderr %q", wantCode, want)
138+ }
139+ for _, args := range []string{"help", "-help", "-h"} {
140+ stdout, stderr, code := run(args)
141+ if stderr != want || stdout != "" || code != 0 {
142+ t.Errorf("mm %s: exit %d, stdout %q, stderr differs from mm --help: %v", args, code, stdout, stderr != want)
143+ }
144+ }
145+}
@@ -5,6 +5,7 @@ import (
5 "errors"5 "errors"
6 "os"6 "os"
7 "os/exec"7 "os/exec"
8+ "path/filepath"
8 "slices"9 "slices"
9 "strings"10 "strings"
10 "testing"11 "testing"
@@ -100,3 +101,45 @@ func withoutEnv(names ...string) []string {
100 }101 }
101 return out102 return out
102 }103 }
104+
105+// Ticket 273: `mm help` is exactly `mm --help` and `mm -help` — the same
106+// text on stderr, nothing on stdout, exit code 0 — even with a file called
107+// `help` in the directory. The real main runs in a child process, as above.
108+func TestHelpIsTheSameAsDashHelp(t *testing.T) {
109+ if os.Getenv("MM_TEST_RUN_MAIN") == "1" {
110+ os.Args = append([]string{"mm"}, strings.Fields(os.Getenv("MM_TEST_ARGS"))...)
111+ main()
112+ os.Exit(0)
113+ }
114+ dir := t.TempDir()
115+ if err := os.WriteFile(filepath.Join(dir, "help"), []byte("provider: dmr\nmodel: x\n"), 0o644); err != nil {
116+ t.Fatal(err)
117+ }
118+ run := func(args string) (string, string, int) {
119+ cmd := exec.Command(os.Args[0], "-test.run=^TestHelpIsTheSameAsDashHelp$")
120+ cmd.Dir = dir
121+ cmd.Env = append(withoutEnv("AGENT_CONFIG", "MM_CONFIG"), "MM_TEST_RUN_MAIN=1", "MM_TEST_ARGS="+args)
122+ var stdout, stderr bytes.Buffer
123+ cmd.Stdout, cmd.Stderr = &stdout, &stderr
124+ cmd.Stdin = strings.NewReader("")
125+ err := cmd.Run()
126+ code := 0
127+ var exit *exec.ExitError
128+ if errors.As(err, &exit) {
129+ code = exit.ExitCode()
130+ } else if err != nil {
131+ t.Fatal(err)
132+ }
133+ return stdout.String(), stderr.String(), code
134+ }
135+ _, want, wantCode := run("--help")
136+ if wantCode != 0 || !strings.Contains(want, "Usage of ") || !strings.Contains(want, "-version") {
137+ t.Fatalf("mm --help: exit %d, stderr %q", wantCode, want)
138+ }
139+ for _, args := range []string{"help", "-help", "-h"} {
140+ stdout, stderr, code := run(args)
141+ if stderr != want || stdout != "" || code != 0 {
142+ t.Errorf("mm %s: exit %d, stdout %q, stderr differs from mm --help: %v", args, code, stdout, stderr != want)
143+ }
144+ }
145+}