commandline

package
v1.1.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package commandline is responsible for creating, parsing and validating command line arguments.

Index

Constants

View Source
const AutocompleteBash = "bash"
View Source
const AutocompletePowershell = "powershell"
View Source
const CredentialsAuth = "credentials"
View Source
const DefinitionsDirectory = "definitions"
View Source
const FlagNameDebug = "debug"
View Source
const FlagNameFile = "file"
View Source
const FlagNameHelp = "help"
View Source
const FlagNameIdentityUri = "identity-uri"
View Source
const FlagNameInsecure = "insecure"
View Source
const FlagNameOrganization = "organization"
View Source
const FlagNameOutputFormat = "output"
View Source
const FlagNameProfile = "profile"
View Source
const FlagNameQuery = "query"
View Source
const FlagNameServiceVersion = "service-version"
View Source
const FlagNameTenant = "tenant"
View Source
const FlagNameUri = "uri"
View Source
const FlagNameVersion = "version"
View Source
const FlagNameWait = "wait"
View Source
const FlagNameWaitTimeout = "wait-timeout"
View Source
const FlagValueFromStdIn = "-"
View Source
const FlagValueOutputFormatJson = "json"
View Source
const FlagValueOutputFormatText = "text"
View Source
const LoginAuth = "login"
View Source
const OperationCommandHelpTemplate = `` /* 590-byte string literal not displayed */
View Source
const PatAuth = "pat"

Variables

View Source
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 BashrcPath added in v1.0.3

func BashrcPath() (string, error)

Returns .bashrc path on linux

func PowershellProfilePath added in v1.0.3

func PowershellProfilePath() (string, error)

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.

func NewCli added in v1.0.57

func NewCli(
	stdIn io.Reader,
	stdOut io.Writer,
	stdErr io.Writer,
	colors bool,
	definitionProvider DefinitionProvider,
	configProvider config.ConfigProvider,
	executor executor.Executor,
	pluginExecutor executor.Executor,
) *Cli

func (Cli) Run

func (c Cli) Run(args []string, input utils.Stream) error

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

type DefinitionData struct {
	Name           string
	ServiceVersion string
	Data           []byte
}

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.

const (
	FlagTypeString FlagType = iota + 1
	FlagTypeInteger
	FlagTypeBoolean
	FlagTypeStringArray
)

func (FlagType) String added in v1.1.2

func (t FlagType) String() string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL