diff --git a/commandline/command_builder.go b/commandline/command_builder.go index 1fc6b3c..8b85782 100644 --- a/commandline/command_builder.go +++ b/commandline/command_builder.go @@ -716,7 +716,7 @@ func (b CommandBuilder) createConfigSetCommand() *cli.Command { } func (b CommandBuilder) loadDefinitions(args []string, version string) ([]parser.Definition, error) { - if len(args) <= 1 || strings.HasPrefix(args[1], "--") { + if len(args) <= 1 || strings.HasPrefix(args[1], "-") { return b.DefinitionProvider.Index(version) } if len(args) > 1 && args[1] == "commands" { diff --git a/main_test.go b/main_test.go index 3bf99cb..c14ea71 100644 --- a/main_test.go +++ b/main_test.go @@ -31,6 +31,24 @@ func TestMainReadsDefinitions(t *testing.T) { } } +func TestHelpReadsDefinitions(t *testing.T) { + config := createFile(t, ".uipath", "config") + definition := createFile(t, "definitions", "service-a.yaml") + + t.Setenv("UIPATH_CONFIGURATION_PATH", config) + t.Setenv("UIPATH_DEFINITIONS_PATH", filepath.Dir(definition)) + + os.Args = []string{"uipath", "-h"} + output := captureOutput(t, func() { + main() + }) + + expected := `service-a` + if !strings.Contains(output, expected) { + t.Errorf("Expected %s in output, but got: %v", expected, output) + } +} + func TestMainParsesDefinition(t *testing.T) { config := createFile(t, ".uipath", "config") definition := createFile(t, "definitions", "service-a.yaml")