Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions plugins/components/conversionlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/jfrog/gofrog/datastructures"
"github.com/jfrog/jfrog-cli-core/v2/docs/common"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/urfave/cli"
)
Expand Down Expand Up @@ -80,7 +79,7 @@ func convertCommand(cmd Command, namespaces ...string) (cli.Command, error) {
if err != nil {
return cli.Command{}, err
}
return cli.Command{
cliCmd := cli.Command{
Name: cmd.Name,
Flags: convertedFlags,
Aliases: cmd.Aliases,
Expand All @@ -93,9 +92,12 @@ func convertCommand(cmd Command, namespaces ...string) (cli.Command, error) {
BashComplete: common.CreateBashCompletionFunc(),
SkipFlagParsing: cmd.SkipFlagParsing,
Hidden: cmd.Hidden,
}
if cmd.Action != nil {
// Passing any other interface than 'cli.ActionFunc' will fail the command.
Action: getActionFunc(cmd),
}, nil
cliCmd.Action = getActionFunc(cmd)
}
return cliCmd, nil
}

func removeEmptyValues(slice []string) []string {
Expand All @@ -112,8 +114,8 @@ func removeEmptyValues(slice []string) []string {
func createCommandUsages(cmd Command, convertedStringFlags map[string]StringFlag, namespaces ...string) (usages []string, err error) {
// Handle manual usages provided.
if cmd.UsageOptions != nil {
for _, manualUsage := range cmd.UsageOptions.Usage {
usages = append(usages, fmt.Sprintf("%s %s", coreutils.GetCliExecutableName(), manualUsage))
if cmd.UsageOptions.Usage != nil {
usages = append(usages, cmd.UsageOptions.Usage...)
}
if cmd.UsageOptions.ReplaceAutoGeneratedUsage {
return
Expand Down
7 changes: 1 addition & 6 deletions plugins/components/conversionlayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"testing"

"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/stretchr/testify/assert"
"github.com/urfave/cli"
)
Expand All @@ -20,11 +19,7 @@ func TestCreateCommandUsages(t *testing.T) {
strFlag := NewStringFlag("flag", "", SetMandatory())

override := []string{"usage override", "usage override 2", "usage override 3"}
expectedOverride := []string{
fmt.Sprintf("%s %s", coreutils.GetCliExecutableName(), "usage override"),
fmt.Sprintf("%s %s", coreutils.GetCliExecutableName(), "usage override 2"),
fmt.Sprintf("%s %s", coreutils.GetCliExecutableName(), "usage override 3"),
}
expectedOverride := override

tests := []struct {
name string
Expand Down
Loading