Documentation
¶
Index ¶
- func Action(providers ...ProviderFunc) func(c *cli.Context) error
- func BaseAppSetup(flags []cli.Flag, commands []cli.Command) (app *cli.App, err error)
- func GenerateCommandsHelp(cmds []cli.Command) string
- func GenerateSubcommandsUsage(cmd cli.Command, prefix string) (commandsUsage []string)
- func GlobalFlags() (flags []cli.Flag)
- func OutputFlags(thing string, jsonType string) []cli.Flag
- func SetClientAndConfig(app *cli.App, client lib.Client, config config.Manager)
- func SetPrompter(app *cli.App, prompter util.Prompter)
- type CliContextWrapper
- type Context
- func (c *Context) App() *cli.App
- func (c *Context) Args() []string
- func (c *Context) Bool(flagname string) bool
- func (c *Context) Client() lib.Client
- func (c *Context) Command() cli.Command
- func (c *Context) Config() config.Manager
- func (ctx *Context) Debug(format string, values ...interface{})
- func (ctx *Context) Debugf(format string, values ...interface{})
- func (c *Context) ErrWriter() io.Writer
- func (c *Context) Help(whatsyourproblem string) (err error)
- func (c *Context) Int(flagname string) int
- func (c *Context) Int64(flagname string) int64
- func (c *Context) IsSet(flagName string) bool
- func (c *Context) IsTest() bool
- func (ctx *Context) Log(format string, values ...interface{})
- func (ctx *Context) LogErr(format string, values ...interface{})
- func (ctx *Context) LogErrf(format string, values ...interface{})
- func (ctx *Context) Logf(format string, values ...interface{})
- func (c *Context) NextArg() (string, error)
- func (ctx *Context) OutputFormat(defaultFormat ...output.Format) (output.Format, error)
- func (ctx *Context) OutputInDesiredForm(obj output.Outputtable, defaultFormat ...output.Format) error
- func (c *Context) Preprocess() error
- func (c *Context) Prompter() util.Prompter
- func (c *Context) Reset()
- func (c *Context) String(flagname string) string
- func (c *Context) StringSlice(flagname string) []string
- func (c *Context) Writer() io.Writer
- type Preprocesser
- type ProviderFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Action ¶
func Action(providers ...ProviderFunc) func(c *cli.Context) error
Action is a convenience function for making cli.Command.Actions that sets up a Context, runs all the providers, cleans up afterward and returns errors from the actions if there is one
func BaseAppSetup ¶
BaseAppSetup sets up a cli.App for the given commands and config
func GenerateCommandsHelp ¶
GenerateCommandsHelp creates a list of commands along with their usages.
func GenerateSubcommandsUsage ¶
GenerateSubcommandsUsage provides a list of usage information recursively for each subcommand, or just for this command if it has no subcommands.
func GlobalFlags ¶
GlobalFlags returns a new set of global flags for the client. This is where they are defined.
func OutputFlags ¶
OutputFlags creates some cli.Flags for when you wanna use OutputInDesiredForm thing should be like "server", "servers", "group", "groups" jsonType should be "array" or "object"
func SetClientAndConfig ¶
SetClientAndConfig adds the client and config to the given app. it abstracts away setting the Metadata on the app. Mostly so that we get some type-checking. without it - it's just assigning to an interface{} which will always succeed, and which would near-inevitably result in hard-to-debug null pointer errors down the line.
func SetPrompter ¶
SetPrompter sets the prompter for the given app. It does not normally need to be set (as this is done for you when calling SetClientAndConfig in cmd/bytemark.main() ) This is used by command tests such as TestDeleteGroup in cmd/bytemark/commands/delete/group_test.go to allow for mocking user input. See that test, or cmd/bytemark/app/auth/authenticator_test.go for example usage of a mock Prompter.
Types ¶
type CliContextWrapper ¶
CliContextWrapper is a struct which embeds cli.Context and is used to ensure that the entirety of innerContext is implemented on it. This allows for making mocks of cli.Contexts. App() and Command() are the methods unique to innerContext that are not in cli.Context
func (CliContextWrapper) App ¶
func (c CliContextWrapper) App() *cli.App
App returns the app for this Context
func (CliContextWrapper) Command ¶
func (c CliContextWrapper) Command() cli.Command
Command returns the Command that was run to create this Context
type Context ¶
type Context struct { Context innerContext Account *lib.Account Authed bool Definitions *lib.Definitions Disc *brain.Disc Group *brain.Group Privilege brain.Privilege User *brain.User VirtualMachine *brain.VirtualMachine // contains filtered or unexported fields }
Context is a wrapper around urfave/cli.Context which provides easy access to the next unused argument and can have various bytemarky types attached to it in order to keep code DRY
func (*Context) App ¶
App returns the cli.App that this context is part of. Usually this will be the same as global.App, but it's nice to depend less on globals.
func (*Context) Debug ¶
Debug runs fmt.Fprintf on the args, outputting to the App's debugWriter. In tests, this is a TestWriter. Otherwise it's nil for now - but might be changed to the debug.log File in the future.
func (*Context) Debugf ¶
Debugf is the same as Debug, but does not append a \n to the format specified
func (*Context) ErrWriter ¶
ErrWriter returns the app writer. just a convenience method for c.App().ErrWriter
func (*Context) Help ¶
Help creates a UsageDisplayedError that will output the issue and a message to consult the documentation
func (*Context) IsTest ¶
IsTest returns whether this app is being run as part of a test It uses the "buf" on the App's Metadata - which is added by app_test.BaseTestSetup and used to capture output for later assertions
func (*Context) LogErrf ¶
LogErrf is the same as LogErr, but does not append a \n to the format specified
func (*Context) OutputFormat ¶
OutputFormat attempts to figure out the output format needed, given the contents of the output-format config var, the json flag, and the table and table-fields flag. If there is an error reading the config, it is returned and human output is assumed.
func (*Context) OutputInDesiredForm ¶
func (ctx *Context) OutputInDesiredForm(obj output.Outputtable, defaultFormat ...output.Format) error
OutputInDesiredForm outputs obj as a JSON object if --json is set, or as a table / table row if --table is set otherwise calls humanOutputFn (which should output it in a very human form - PrettyPrint or such defaultFormat is an optional string stating what the default format should be
func (*Context) Preprocess ¶
Preprocess runs the Preprocess methods on all flags that implement Preprocessor
func (*Context) Prompter ¶
Prompter returns the prompter which is used by this Context for prompting the user for input
func (*Context) Reset ¶
func (c *Context) Reset()
Reset replaces the Context with a blank one (keeping the cli.Context)
func (*Context) StringSlice ¶
StringSlice returns the values of the named flag as a []string
type Preprocesser ¶
A Preprocesser is a flag.Flag that has a preprocess step that requires a Context
type ProviderFunc ¶
ProviderFunc is the function type that can be passed to Action()
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
gen/slice_flags
slice_flags is a tool to instantly implement a flag.Value called <Something>SliceFlag, which contains a slice of <Something>Flags, an accessor called <Something>Slice, and a test to ensure that the SliceFlag parses and Preprocesses correctly if necessary.
|
slice_flags is a tool to instantly implement a flag.Value called <Something>SliceFlag, which contains a slice of <Something>Flags, an accessor called <Something>Slice, and a test to ensure that the SliceFlag parses and Preprocesses correctly if necessary. |