app

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2023 License: MIT Imports: 22 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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 InsecureAction(c *cli.Context) error

func LanguageAction

func LanguageAction(c *cli.Context) error

func LogAction

func LogAction(c *cli.Context) error

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

func LogFileAction(c *cli.Context) error

LogFileAction is an action routine to set the name of the output log file.

func Logon

func Logon(c *cli.Context) error

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

func OutputFormatAction(c *cli.Context) error

OutputFormatAction sets the default output format to use. This must be one of the supported types "test"", "json"", or "indented").

func QuietAction

func QuietAction(c *cli.Context) error

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

func ShowVersionAction(c *cli.Context) error

ShowVersionAction is the action routine called when --version is specified. It prints the version number information and then exits the application.

func UseProfileAction

func UseProfileAction(c *cli.Context) error

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

func VersionAction(c *cli.Context) error

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 New

func New(appName string) *App

New creates a new instance of an application context, given the name of the application.

func (*App) Parse

func (app *App) Parse(grammar []cli.Option, args []string, action func(c *cli.Context) error) error

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

func (app *App) Run(grammar []cli.Option, args []string) error

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

func (app *App) SetBuildTime(s string) *App

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

func (app *App) SetCopyright(s string) *App

SetCopyright sets the copyright string (if any) used in the help output.

func (*App) SetDefaultAction

func (app *App) SetDefaultAction(f func(c *cli.Context) error) *App

func (*App) SetVersion

func (app *App) SetVersion(major, minor, delta int) *App

SetVersion sets the version number for the application.

Jump to

Keyboard shortcuts

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