Documentation ¶
Overview ¶
Package commandline is responsible for creating, parsing and validating command line arguments.
Index ¶
- Constants
- Variables
- func BashrcPath() (string, error)
- func PowershellProfilePath() (string, error)
- type Cli
- type CommandBuilder
- type CommandDefinition
- func (c *CommandDefinition) WithAction(action CommandExecFunc) *CommandDefinition
- func (c *CommandDefinition) WithFlags(flags []*FlagDefinition) *CommandDefinition
- func (c *CommandDefinition) WithHelpTemplate(helpTemplate string) *CommandDefinition
- func (c *CommandDefinition) WithHidden(hidden bool) *CommandDefinition
- func (c *CommandDefinition) WithSubcommands(subcommands []*CommandDefinition) *CommandDefinition
- type CommandExecContext
- type CommandExecFunc
- type DefinitionData
- type DefinitionFileStore
- type DefinitionProvider
- type DefinitionStore
- type FlagBuilder
- func (b *FlagBuilder) AddDefaultFlags(hidden bool) *FlagBuilder
- func (b *FlagBuilder) AddFlag(flag *FlagDefinition) *FlagBuilder
- func (b *FlagBuilder) AddFlags(flags []*FlagDefinition) *FlagBuilder
- func (b *FlagBuilder) AddHelpFlag() *FlagBuilder
- func (b *FlagBuilder) AddServiceVersionFlag(hidden bool) *FlagBuilder
- func (b *FlagBuilder) AddVersionFlag() *FlagBuilder
- func (b FlagBuilder) Build() []*FlagDefinition
- type FlagDefinition
- type FlagOptionFunc
- type FlagType
- type UriBuilder
Constants ¶
const AutocompleteBash = "bash"
const AutocompletePowershell = "powershell"
const CredentialsAuth = "credentials"
const DefinitionsDirectory = "definitions"
const FlagNameDebug = "debug"
const FlagNameFile = "file"
const FlagNameHelp = "help"
const FlagNameIdentityUri = "identity-uri"
const FlagNameInsecure = "insecure"
const FlagNameOrganization = "organization"
const FlagNameOutputFormat = "output"
const FlagNameProfile = "profile"
const FlagNameQuery = "query"
const FlagNameServiceVersion = "service-version"
const FlagNameTenant = "tenant"
const FlagNameUri = "uri"
const FlagNameVersion = "version"
const FlagNameWait = "wait"
const FlagNameWaitTimeout = "wait-timeout"
const FlagValueFromStdIn = "-"
const FlagValueOutputFormatJson = "json"
const FlagValueOutputFormatText = "text"
const LoginAuth = "login"
const OperationCommandHelpTemplate = `` /* 590-byte string literal not displayed */
const PatAuth = "pat"
Variables ¶
var FlagNamesPredefined = []string{ FlagNameDebug, FlagNameProfile, FlagNameUri, FlagNameOrganization, FlagNameTenant, FlagNameInsecure, FlagNameOutputFormat, FlagNameQuery, FlagNameWait, FlagNameWaitTimeout, FlagNameFile, FlagNameIdentityUri, FlagNameServiceVersion, FlagNameHelp, FlagNameVersion, }
var Version = "main"
This Version variable is overridden during build time by providing the linker flag: -ldflags="-X github.com/UiPath/uipathcli/commandline.Version=1.2.3"
Functions ¶
func PowershellProfilePath ¶ added in v1.0.3
Returns powershell profile path on linux
Types ¶
type Cli ¶
type Cli struct {
// contains filtered or unexported fields
}
Cli is a wrapper for building the CLI commands.
type CommandBuilder ¶
type CommandBuilder struct { Input utils.Stream StdIn io.Reader StdOut io.Writer StdErr io.Writer ConfigProvider config.ConfigProvider Executor executor.Executor PluginExecutor executor.Executor DefinitionProvider DefinitionProvider }
The CommandBuilder is creating all available operations and arguments for the CLI.
func (CommandBuilder) Create ¶
func (b CommandBuilder) Create(args []string) ([]*CommandDefinition, error)
type CommandDefinition ¶ added in v1.1.2
type CommandDefinition struct { Name string Summary string Description string Flags []*FlagDefinition Subcommands []*CommandDefinition HelpTemplate string Hidden bool Action CommandExecFunc }
The CommandDefinition contains the metadata and builder methods for creating CLI commands.
func NewCommand ¶ added in v1.1.2
func NewCommand(name string, summary string, description string) *CommandDefinition
func (*CommandDefinition) WithAction ¶ added in v1.1.2
func (c *CommandDefinition) WithAction(action CommandExecFunc) *CommandDefinition
func (*CommandDefinition) WithFlags ¶ added in v1.1.2
func (c *CommandDefinition) WithFlags(flags []*FlagDefinition) *CommandDefinition
func (*CommandDefinition) WithHelpTemplate ¶ added in v1.1.2
func (c *CommandDefinition) WithHelpTemplate(helpTemplate string) *CommandDefinition
func (*CommandDefinition) WithHidden ¶ added in v1.1.2
func (c *CommandDefinition) WithHidden(hidden bool) *CommandDefinition
func (*CommandDefinition) WithSubcommands ¶ added in v1.1.2
func (c *CommandDefinition) WithSubcommands(subcommands []*CommandDefinition) *CommandDefinition
type CommandExecContext ¶ added in v1.1.2
type CommandExecContext struct {
*cli.Context
}
The CommandExecContext contains the flag values provided by the user.
type CommandExecFunc ¶ added in v1.1.2
type CommandExecFunc func(*CommandExecContext) error
The CommandExecFunc is the function definition for executing a command action.
type DefinitionData ¶
DefinitionData contains the name of the definition file and its data.
func NewDefinitionData ¶
func NewDefinitionData(name string, serviceVersion string, data []byte) *DefinitionData
type DefinitionFileStore ¶ added in v1.0.57
type DefinitionFileStore struct {
// contains filtered or unexported fields
}
DefinitionFileStore discovers the definition files from disk searching for the definitions/ folder and returns the data for a particular definition file.
func NewDefinitionFileStore ¶ added in v1.0.57
func NewDefinitionFileStore(directory string, embedded embed.FS) *DefinitionFileStore
func NewDefinitionFileStoreWithData ¶ added in v1.0.57
func NewDefinitionFileStoreWithData(data []DefinitionData) *DefinitionFileStore
func (*DefinitionFileStore) Names ¶ added in v1.0.57
func (s *DefinitionFileStore) Names(serviceVersion string) ([]string, error)
func (*DefinitionFileStore) Read ¶ added in v1.0.57
func (s *DefinitionFileStore) Read(name string, serviceVersion string) (*DefinitionData, error)
type DefinitionProvider ¶ added in v1.0.17
type DefinitionProvider struct {
// contains filtered or unexported fields
}
The DefinitionProvider uses the store to read the definition files. It parses the definition files and also supports merging multiple files for the same service.
The following mapping is performed between the files on disk and the commands the CLI provides: orchestrator.yaml => uipath orchestrator ... du.metering.yaml => uipath du ... du.events.yaml => uipath du ...
For performance reasons, the definition provider always just loads the definition files belonging to a single service. There is no need to load the definition file for the du service when the user executes 'uipath orchestrator', for example.
func NewDefinitionProvider ¶ added in v1.0.57
func NewDefinitionProvider(store DefinitionStore, parser parser.Parser, commandPlugins []plugin.CommandPlugin) *DefinitionProvider
func (DefinitionProvider) Index ¶ added in v1.0.17
func (p DefinitionProvider) Index(serviceVersion string) ([]parser.Definition, error)
func (DefinitionProvider) Load ¶ added in v1.0.17
func (p DefinitionProvider) Load(name string, serviceVersion string) (*parser.Definition, error)
type DefinitionStore ¶ added in v1.0.17
type DefinitionStore interface { Names(serviceVersion string) ([]string, error) Read(name string, serviceVersion string) (*DefinitionData, error) }
DefinitionStore is used to provide the names and content of definition files.
type FlagBuilder ¶ added in v1.1.2
type FlagBuilder struct {
// contains filtered or unexported fields
}
The FlagBuilder can be used to prepare a list of flags for a CLI command. The builder takes care that flags with the same name are deduped.
func NewFlagBuilder ¶ added in v1.1.2
func NewFlagBuilder() *FlagBuilder
func (*FlagBuilder) AddDefaultFlags ¶ added in v1.1.2
func (b *FlagBuilder) AddDefaultFlags(hidden bool) *FlagBuilder
func (*FlagBuilder) AddFlag ¶ added in v1.1.2
func (b *FlagBuilder) AddFlag(flag *FlagDefinition) *FlagBuilder
func (*FlagBuilder) AddFlags ¶ added in v1.1.2
func (b *FlagBuilder) AddFlags(flags []*FlagDefinition) *FlagBuilder
func (*FlagBuilder) AddHelpFlag ¶ added in v1.1.2
func (b *FlagBuilder) AddHelpFlag() *FlagBuilder
func (*FlagBuilder) AddServiceVersionFlag ¶ added in v1.1.3
func (b *FlagBuilder) AddServiceVersionFlag(hidden bool) *FlagBuilder
func (*FlagBuilder) AddVersionFlag ¶ added in v1.1.2
func (b *FlagBuilder) AddVersionFlag() *FlagBuilder
func (FlagBuilder) Build ¶ added in v1.1.2
func (b FlagBuilder) Build() []*FlagDefinition
type FlagDefinition ¶ added in v1.1.2
type FlagDefinition struct { Name string Summary string Type FlagType EnvVarName string DefaultValue interface{} Hidden bool Required bool }
The FlagDefinition contains the metadata and builder methods for creating command line flags.
func NewFlag ¶ added in v1.1.2
func NewFlag(name string, summary string, flagType FlagType) *FlagDefinition
func (*FlagDefinition) WithDefaultValue ¶ added in v1.1.2
func (f *FlagDefinition) WithDefaultValue(value interface{}) *FlagDefinition
func (*FlagDefinition) WithEnvVarName ¶ added in v1.1.2
func (f *FlagDefinition) WithEnvVarName(envVarName string) *FlagDefinition
func (*FlagDefinition) WithHidden ¶ added in v1.1.2
func (f *FlagDefinition) WithHidden(hidden bool) *FlagDefinition
func (*FlagDefinition) WithRequired ¶ added in v1.1.2
func (f *FlagDefinition) WithRequired(required bool) *FlagDefinition
type FlagOptionFunc ¶ added in v1.1.2
type FlagOptionFunc func(*FlagDefinition)
type FlagType ¶ added in v1.1.2
type FlagType int
The FlagType is an enum of the supported flag definition types.
type UriBuilder ¶ added in v1.0.5
type UriBuilder struct {
// contains filtered or unexported fields
}
UriBuilder merges parts of the uri so that they can be overridden from multiple sources, like environment variables, config files or command line arguments.
func NewUriBuilder ¶ added in v1.0.5
func NewUriBuilder(uri url.URL) *UriBuilder
func (*UriBuilder) OverrideUri ¶ added in v1.0.5
func (b *UriBuilder) OverrideUri(overrideUri *url.URL)
func (UriBuilder) Uri ¶ added in v1.0.5
func (b UriBuilder) Uri() url.URL
Source Files ¶
- autocomplete_folder_notwin.go
- autocomplete_handler.go
- cli.go
- command_builder.go
- command_definition.go
- config_command_handler.go
- definition_data.go
- definition_file_store.go
- definition_provider.go
- definition_store.go
- flag_builder.go
- flag_definition.go
- flag_type.go
- help_templates.go
- multi_definition.go
- parameter_formatter.go
- show_command_handler.go
- type_converter.go
- uri_builder.go
- version_command_handler.go