fix(cli): honor local installation discovery precedence

This commit is contained in:
2026-08-15 22:29:55 +02:00
parent 66614fe8cf
commit 2c800cc521
4 changed files with 83 additions and 21 deletions
+9 -5
View File
@@ -81,11 +81,11 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer) int {
fmt.Fprintf(stderr, "tht: %s\n\n%s", err, usage)
return 2
}
if command == "help" && len(commandArgs) == 0 {
fmt.Fprint(stdout, usage)
return 0
}
if (command == "version" || command == "setup") && len(commandArgs) == 0 {
if isBootstrapCommand(command) {
if command == "help" {
fmt.Fprint(stdout, usage)
return 0
}
return commandUsageError(stderr, fmt.Sprintf("unknown command %q", command))
}
workingDirectory, err := os.Getwd()
@@ -194,6 +194,10 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer) int {
return writeResult(result, err, secretValues, stdout, stderr)
}
func isBootstrapCommand(command string) bool {
return command == "help" || command == "setup" || command == "version"
}
func writeRemovalTargets(outputWriter io.Writer, project string, targets []serverops.Container) {
fmt.Fprintf(outputWriter, "Removal targets for installation project %s:\n", project)
if len(targets) == 0 {
+9 -1
View File
@@ -90,7 +90,15 @@ func TestBootstrapCommandsDoNotRequireAnInstallationDescriptor(t *testing.T) {
})
t.Setenv("THOTHII_INSTALLATION", "")
for _, args := range [][]string{nil, {"help"}, {"version"}, {"setup"}} {
for _, args := range [][]string{
nil,
{"help"},
{"help", "pi"},
{"version"},
{"version", "--json"},
{"setup"},
{"setup", "--configure-only"},
} {
var stdout, stderr bytes.Buffer
_ = run(context.Background(), args, &stdout, &stderr)
if output := stdout.String() + stderr.String(); strings.Contains(output, "installation descriptor") {