fix(cli): honor local installation discovery precedence
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user