From 7315f2658cd83f645c1070ba86b279f880bb5db5 Mon Sep 17 00:00:00 2001 From: thibaud-lclr Date: Wed, 15 Apr 2026 09:57:43 +0200 Subject: [PATCH] fix(cli): rely on framework doctor alias --- internal/cli/app.go | 43 +++++----------------------------------- internal/cli/app_test.go | 2 +- 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/internal/cli/app.go b/internal/cli/app.go index 2add796..be3cf51 100644 --- a/internal/cli/app.go +++ b/internal/cli/app.go @@ -115,7 +115,10 @@ func NewAppWithDependencies( } func (a *App) Run(args []string) error { - return a.runBootstrap(context.Background(), normalizeArgs(args)) + if args == nil { + args = []string{} + } + return a.runBootstrap(context.Background(), args) } func (a *App) runBootstrap(ctx context.Context, args []string) error { @@ -125,6 +128,7 @@ func (a *App) runBootstrap(ctx context.Context, args []string) error { BinaryName: metadata.BinaryName, Description: metadata.Description, Version: a.version, + EnableDoctorAlias: true, Args: args, Stdin: a.stdin, Stdout: a.stdout, @@ -778,40 +782,3 @@ func newUserFacingError(message string, err error) error { err: err, } } - -func normalizeArgs(args []string) []string { - if len(args) == 0 { - return []string{} - } - - normalized := append([]string(nil), args...) - for i, arg := range normalized { - normalized[i] = strings.TrimSpace(arg) - } - - switch normalized[0] { - case "doctor": - if len(normalized) == 1 { - return []string{frameworkbootstrap.CommandConfig, frameworkbootstrap.ConfigSubcommandTest} - } - - lastArg := normalized[len(normalized)-1] - if lastArg == "-h" || lastArg == "--help" { - return []string{"help", frameworkbootstrap.CommandConfig, frameworkbootstrap.ConfigSubcommandTest} - } - - return append( - []string{frameworkbootstrap.CommandConfig, frameworkbootstrap.ConfigSubcommandTest}, - normalized[1:]..., - ) - case "help": - if len(normalized) > 1 && normalized[1] == "doctor" { - return append( - []string{"help", frameworkbootstrap.CommandConfig, frameworkbootstrap.ConfigSubcommandTest}, - normalized[2:]..., - ) - } - } - - return normalized -} diff --git a/internal/cli/app_test.go b/internal/cli/app_test.go index 1550ab6..4abfc53 100644 --- a/internal/cli/app_test.go +++ b/internal/cli/app_test.go @@ -158,7 +158,7 @@ func TestAppRunShowsUsageWhenNoArgsProvided(t *testing.T) { } text := output.String() - for _, snippet := range []string{"Usage:", "config", "version"} { + for _, snippet := range []string{"Usage:", "config", "version", `doctor Diagnostiquer la configuration locale. (alias de "config test").`} { if !strings.Contains(text, snippet) { t.Fatalf("help output missing %q: %q", snippet, text) }