Skip to content

Commit

Permalink
Merge pull request #118 from UiPath/fix/short-help-option
Browse files Browse the repository at this point in the history
Fix commands section in short help command (-h)
  • Loading branch information
thschmitt authored May 23, 2024
2 parents 022c5d8 + eadf002 commit 99f6ece
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion commandline/command_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
18 changes: 18 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 99f6ece

Please sign in to comment.