Documentation
¶
Overview ¶
Package cliutil contains methods used across all cli commands @todo: get rid of os.Exits and use errors instread
Index ¶
- func AddMetadataToContext(ctx context.Context, metadataStrings []string) context.Context
- func CallService(srv *registry.Service, args []string) error
- func CliError(err error) cli.ExitCoder
- func FlagsToRequest(flags map[string][]string, req *registry.Value) (map[string]interface{}, error)
- func FormatServiceUsage(srv *registry.Service, c *cli.Context) string
- func LookupService(name string) (*registry.Service, error)
- func Print(e Exec) func(*cli.Context) error
- func ShouldRenderHelp(args []string) bool
- type Exec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddMetadataToContext ¶
AddMetadataToContext parses metadata strings in the format "Key:Value" and adds them to the context
func CallService ¶
CallService will call a service using the arguments and flags provided in the context. It will print the result or error to stdout. If there was an error performing the call, it will be returned.
func CliError ¶
CliError returns a user friendly message from error. If we can't determine a good one returns an error with code 128
func FlagsToRequest ¶
FlagsToRequest parses a set of flags, e.g {name:"Foo", "options_surname","Bar"} and converts it into a request body. If the key is not a valid object in the request, an error will be returned.
This function constructs []interface{} slices as opposed to typed ([]string etc) slices for easier testing
func FormatServiceUsage ¶
FormatServiceUsage returns a string containing the service usage.
func LookupService ¶
LookupService queries the service for a service with the given alias. If no services are found for a given alias, the registry will return nil and the error will also be nil. An error is only returned if there was an issue listing from the registry.
func ShouldRenderHelp ¶
ShouldRenderHelp returns true if the help flag was passed