MCPcopy Create free account
hub / github.com/UiPath/uipathcli / convertCommand

Method convertCommand

commandline/cli.go:131–158  ·  view source on GitHub ↗
(command *CommandDefinition)

Source from the content-addressed store, hash-verified

129}
130
131func (c Cli) convertCommand(command *CommandDefinition) *cli.Command {
132 result := cli.Command{
133 Name: command.Name,
134 Usage: command.Summary,
135 Description: command.Description,
136 Flags: c.convertFlags(command.Flags...),
137 Commands: c.convertCommands(command.Subcommands...),
138 CustomHelpTemplate: command.HelpTemplate,
139 Hidden: command.Hidden,
140 HideHelp: true,
141 DisableSliceFlagSeparator: true,
142 CommandNotFound: func(ctx context.Context, cmd *cli.Command, commandName string) {
143 if cmd != nil {
144 root := cmd.Root()
145 root.CommandNotFound(ctx, cmd, commandName)
146 }
147 },
148 OnUsageError: func(ctx context.Context, cmd *cli.Command, err error, isSubcommand bool) error {
149 return fmt.Errorf("Incorrect usage: %w", err)
150 },
151 }
152 if command.Action != nil {
153 result.Action = func(ctx context.Context, cmd *cli.Command) error {
154 return command.Action(&CommandExecContext{cmd, ctx})
155 }
156 }
157 return &result
158}
159
160func (c Cli) convertCommands(commands ...*CommandDefinition) []*cli.Command {
161 result := []*cli.Command{}

Callers 1

convertCommandsMethod · 0.95

Calls 2

convertFlagsMethod · 0.95
convertCommandsMethod · 0.95

Tested by

no test coverage detected