(ctx context.Context, args []string, input stream.Stream)
| 28 | } |
| 29 | |
| 30 | func (c Cli) run(ctx context.Context, args []string, input stream.Stream) error { |
| 31 | err := c.configProvider.Load() |
| 32 | if err != nil { |
| 33 | return err |
| 34 | } |
| 35 | |
| 36 | CommandBuilder := CommandBuilder{ |
| 37 | Input: input, |
| 38 | StdIn: c.stdIn, |
| 39 | StdOut: c.stdOut, |
| 40 | StdErr: c.stdErr, |
| 41 | ConfigProvider: c.configProvider, |
| 42 | Executor: c.executor, |
| 43 | PluginExecutor: c.pluginExecutor, |
| 44 | DefinitionProvider: c.definitionProvider, |
| 45 | } |
| 46 | |
| 47 | flags := NewFlagBuilder(). |
| 48 | AddDefaultFlags(false). |
| 49 | AddVersionFlag(). |
| 50 | Build() |
| 51 | |
| 52 | commands, err := CommandBuilder.Create(args) |
| 53 | if err != nil { |
| 54 | return err |
| 55 | } |
| 56 | |
| 57 | var commandError error |
| 58 | app := &cli.Command{ |
| 59 | Name: "uipath", |
| 60 | Usage: "Command-Line Interface for UiPath Services", |
| 61 | UsageText: "uipath <service> <operation> --<argument> <value>", |
| 62 | Version: "1.0", |
| 63 | Flags: c.convertFlags(flags...), |
| 64 | Commands: c.convertCommands(commands...), |
| 65 | Writer: c.stdOut, |
| 66 | ErrWriter: c.stdErr, |
| 67 | HideVersion: true, |
| 68 | HideHelpCommand: true, |
| 69 | DisableSliceFlagSeparator: true, |
| 70 | CommandNotFound: func(ctx context.Context, cmd *cli.Command, commandName string) { |
| 71 | commandError = fmt.Errorf("Command '%s' not found", commandName) |
| 72 | }, |
| 73 | OnUsageError: func(ctx context.Context, cmd *cli.Command, err error, isSubcommand bool) error { |
| 74 | return fmt.Errorf("Incorrect usage: %w", err) |
| 75 | }, |
| 76 | Action: func(ctx context.Context, cmd *cli.Command) error { |
| 77 | if cmd.IsSet(FlagNameVersion) { |
| 78 | handler := newVersionCommandHandler(c.stdOut) |
| 79 | return handler.Execute() |
| 80 | } |
| 81 | if len(args) <= 1 { |
| 82 | return cli.ShowAppHelp(cmd) |
| 83 | } |
| 84 | |
| 85 | if strings.HasPrefix(args[1], "--") { |
| 86 | return errors.New(`No command provided. |
| 87 |
no test coverage detected