diff --git a/cli/dispatcher/internal/dispatcher/dispatcher_v2_run.go b/cli/dispatcher/internal/dispatcher/dispatcher_v2_run.go index a36560fc5f..a85f2d7998 100644 --- a/cli/dispatcher/internal/dispatcher/dispatcher_v2_run.go +++ b/cli/dispatcher/internal/dispatcher/dispatcher_v2_run.go @@ -87,6 +87,12 @@ func dispatcherV2ProjectDetectedError(projectRoot string, v2Project dispatcherV2 } } +// dispatcherV2ModeNotice builds the stderr notice announcing delegation to the V2 CLI. +// Why: delegation happens implicitly, so the executed CLI generation and version are otherwise invisible to the caller. +func dispatcherV2ModeNotice(version string) string { + return "uloop: executing in V2 mode (" + dispatcherV2CLIPackageName + "@" + version + ")\n" +} + // runDispatcherV2CLI installs and executes the V2 CLI while preserving the original command arguments. // Why: the dispatcher must select the CLI generation before command parsing can change user-supplied arguments. func runDispatcherV2CLI(ctx context.Context, version string, args []string, stdout io.Writer, stderr io.Writer) (int, error) { @@ -106,7 +112,7 @@ func runDispatcherV2CLI(ctx context.Context, version string, args []string, stdo if err != nil { return 0, err } - _, err = io.WriteString(stderr, "uloop: executing in V2 mode\n") + _, err = io.WriteString(stderr, dispatcherV2ModeNotice(version)) if err != nil { return 0, err } diff --git a/cli/dispatcher/internal/dispatcher/dispatcher_v2_run_test.go b/cli/dispatcher/internal/dispatcher/dispatcher_v2_run_test.go new file mode 100644 index 0000000000..8770586a95 --- /dev/null +++ b/cli/dispatcher/internal/dispatcher/dispatcher_v2_run_test.go @@ -0,0 +1,13 @@ +package dispatcher + +import "testing" + +func TestDispatcherV2ModeNoticeReportsDelegatedPackageAndVersion(t *testing.T) { + // Verifies the notice names the delegated V2 CLI package and its version so the caller can identify the executed generation. + notice := dispatcherV2ModeNotice("2.2.0") + + want := "uloop: executing in V2 mode (" + dispatcherV2CLIPackageName + "@2.2.0)\n" + if notice != want { + t.Fatalf("notice = %q, want %q", notice, want) + } +}