Documentation ¶
Overview ¶
Package cmdlib contains shared functions for the bundle CLI commands.
Index ¶
- Variables
- func ExitWithHelp(cmd *cobra.Command, err string)
- func MergeOptions(ctx context.Context, rw files.FileReaderWriter, files []string) (options.JSONOptions, error)
- func ParseStringMap(p string) map[string]string
- type BundleReaderWriter
- type CobraActionFunc
- type ContextActionFunc
- type GlobalOptions
- type RealStdioReaderWriter
- type StdioReaderWriter
Constants ¶
This section is empty.
Variables ¶
var GlobalOptionsValues = &GlobalOptions{}
GlobalOptionsValues is a global tracker for global options (for command line executions only).
Functions ¶
func ExitWithHelp ¶
ExitWithHelp exits and prints the help message.
func MergeOptions ¶ added in v0.9.0
func MergeOptions(ctx context.Context, rw files.FileReaderWriter, files []string) (options.JSONOptions, error)
MergeOptions reads multiple options files and combines them into a single map. Option values will be overwritten if a later file has the same key.
func ParseStringMap ¶ added in v0.9.1
ParseStringMap parses a CLI flag value into a map of string to string. It expects the raw flag value to have the form "key1=value1,key2=value2,etc".
Types ¶
type BundleReaderWriter ¶ added in v0.8.0
type BundleReaderWriter interface { ReadBundleData(context.Context, *GlobalOptions) (*wrapper.BundleWrapper, error) WriteBundleData(context.Context, *wrapper.BundleWrapper, *GlobalOptions) error WriteStructuredContents(context.Context, interface{}, *GlobalOptions) error }
BundleReaderWriter provides a mockable reading / writing interface for reading / writing bundle data.
func NewBundleReaderWriter ¶ added in v0.8.0
func NewBundleReaderWriter(rw files.FileReaderWriter, stdio StdioReaderWriter) BundleReaderWriter
NewBundleReaderWriter creates a new BundleReaderWriter.
type CobraActionFunc ¶
CobraActionFunc provides a common type for all Cobra commands.
func ContextAction ¶
func ContextAction(ctx context.Context, fio files.FileReaderWriter, sio StdioReaderWriter, f ContextActionFunc) CobraActionFunc
ContextAction returns a CobraActionFunc for a provided ContextActionFunc.
type ContextActionFunc ¶
type ContextActionFunc func(ctx context.Context, fio files.FileReaderWriter, sio StdioReaderWriter, cmd *cobra.Command, args []string)
ContextActionFunc is a common type for providing a context to a Cobra function.
type GlobalOptions ¶
type GlobalOptions struct { // InputFile is a path to an input file. If a file is not specified, it's // assumed the input is provided via STDIN. InputFile string // InputFormat is the text format for the input. By default, assumes YAML // but also can be JSON. InputFormat string // OutputFormat is the the format for any output. By default, assumes YAML. OutputFormat string // Inline indicates whether to inline the components in the bundle builders // or component builders before doing any processing. Inline bool }
GlobalOptions are options that apply to all commands
func (*GlobalOptions) Copy ¶
func (g *GlobalOptions) Copy() *GlobalOptions
Copy creates an options copy.
type RealStdioReaderWriter ¶ added in v0.8.0
type RealStdioReaderWriter struct{}
RealStdioReaderWriter provides a real STDIN / STDOUT implementation.
func (*RealStdioReaderWriter) ReadAll ¶ added in v0.8.0
func (r *RealStdioReaderWriter) ReadAll() ([]byte, error)
ReadAll reads all the input from STDIN.