Documentation
¶
Overview ¶
Package cobra integrates chalk with github.com/spf13/cobra (or any other flag library exposing a pflag.FlagSet-shaped API) without importing cobra/pflag directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FlagSet ¶
type FlagSet interface {
BoolVar(p *bool, name string, value bool, usage string)
StringVar(p *string, name string, value string, usage string)
}
FlagSet is the subset of (*pflag.FlagSet) used by BindFlags to register flags. *pflag.FlagSet (e.g. cmd.PersistentFlags()) and stdlib *flag.FlagSet both satisfy this interface.
type Flags ¶
type Flags struct {
NoTTY, NoColor, Silent bool
InputDir, OutputDir, OutputFile string
Extension, Cache string
}
Flags holds chalk's standard CLI flags, populated once fs (passed to BindFlags) has been parsed.
func BindFlags ¶
BindFlags registers chalk's standard flags on fs (e.g. cmd.PersistentFlags()) and returns a *Flags populated once fs is parsed:
f := chalkcobra.BindFlags(cmd.PersistentFlags()) // ... cmd.Execute() parses flags ... r := f.Init()
func (*Flags) Init ¶
Init builds and installs a Reporter from the parsed flag values, and wires the checkpoint cache as checkpoint.Default(), used by Recover/Commit. Call from cmd's RunE/PersistentPreRunE, after cobra has parsed flags.
func (*Flags) Spool ¶
func (f *Flags) Spool(args []string) (src spool.FileSystem, wlk spool.Walker, dst spool.FileSystem, err error)
Spool resolves the input/output file systems and walker from f, for use with github.com/fogfish/stream/spool. args are the positional file arguments (e.g. cmd.Flags().Args()).