Documentation ¶
Overview ¶
Package app provides the top-level framework for CLI execution. This includes the Run() method to run the program, plus a number of action routines that can be invoked from the grammar or by a user action routine. These support common or global actions, like specifying which profile to use.
Index ¶
- Variables
- func InsecureAction(c *cli.Context) error
- func LanguageAction(c *cli.Context) error
- func LogAction(c *cli.Context) error
- func LogFileAction(c *cli.Context) error
- func Logon(c *cli.Context) error
- func OutputFormatAction(c *cli.Context) error
- func QuietAction(c *cli.Context) error
- func SetDefaultLoggers() error
- func ShowVersionAction(c *cli.Context) error
- func UseProfileAction(c *cli.Context) error
- func VersionAction(c *cli.Context) error
- type App
- func (app *App) Parse(grammar []cli.Option, args []string, action func(c *cli.Context) error) error
- func (app *App) Run(grammar []cli.Option, args []string) error
- func (app *App) SetBuildTime(s string) *App
- func (app *App) SetCopyright(s string) *App
- func (app *App) SetDefaultAction(f func(c *cli.Context) error) *App
- func (app *App) SetVersion(major, minor, delta int) *App
Constants ¶
This section is empty.
Variables ¶
var LogonGrammar = []cli.Option{ { LongName: "username", ShortName: "u", OptionType: cli.StringType, Description: "username", EnvironmentVariable: "EGO_USERNAME", }, { LongName: "password", ShortName: "p", OptionType: cli.StringType, Description: "password", EnvironmentVariable: "EGO_PASSWORD", }, { LongName: "logon-server", ShortName: "l", Aliases: []string{"server"}, OptionType: cli.StringType, Description: "logon.server", EnvironmentVariable: "EGO_LOGON_SERVER", }, }
LogonGrammar describes the login subcommand.
Functions ¶
func InsecureAction ¶
func LanguageAction ¶
func LogAction ¶
LogAction is an action routine to set the loggers that will get debug messages during execution. This must be a string list, and each named logger is enabled. If a logger name is not valid, an error is returned.
func LogFileAction ¶
LogFileAction is an action routine to set the name of the output log file.
func Logon ¶
Logon handles the logon subcommand. This accepts a username and password string from the user via the command line, or console input if not provided on the command line. These credentials are used to connect to an Ego logon server and request an authentication token to be used for subsequent operations.
If the user credentials are valid and a token is returned, it is stored in the user's active profile where it can be accessed by other Ego commands as needed.
func OutputFormatAction ¶
OutputFormatAction sets the default output format to use. This must be one of the supported types "test"", "json"", or "indented").
func QuietAction ¶
QuietAction is an action routine to set the global debug status if specified.
func SetDefaultLoggers ¶
func SetDefaultLoggers() error
Enable the loggers that are set using the EGO_DEFAULT_LOOGGERS environment variable.
func ShowVersionAction ¶
ShowVersionAction is the action routine called when --version is specified. It prints the version number information and then exits the application.
func UseProfileAction ¶
UseProfileAction is the action routine when --profile is specified as a global option. Its string value is used as the name of the active profile.
func VersionAction ¶
Types ¶
type App ¶
type App struct { Name string Description string Copyright string Version string BuildTime string Context *cli.Context Action func(c *cli.Context) error }
App is the wrapper type for information needed for a command line application. It contains the globals needed for the application as well as the runtime context root.
func (*App) Parse ¶
Parse runs a grammar, and then calls the provided action routine. It is typically used in cases where there are no subcommands, and an action should be run after parsing options.
func (*App) Run ¶
Run runs a grammar given a set of arguments in the current applciation. The grammar must declare action routines for the various subcommands, which will be executed by the parser.
func (*App) SetBuildTime ¶
Set the build time for the app. If the build time is formatted as a valid build time, it is encoded as an Ego time.Time value and stored in _buildtime. If it is not a valid build time, the string value is stored as-is in the _buildtime global variable.
func (*App) SetCopyright ¶
SetCopyright sets the copyright string (if any) used in the help output.
func (*App) SetVersion ¶
SetVersion sets the version number for the application.