Documentation ¶
Overview ¶
Package compflag provides a handful of standard library-compatible flags with bash complition capabilities.
Usage
import "github.com/posener/complete/v2/compflag" var ( // Define flags... foo = compflag.String("foo", "", "") ) func main() { compflag.Parse() // Main function. }
Alternatively, the library can just be used with the standard library flag package:
import ( "flag" "github.com/posener/complete/v2/compflag" ) var ( // Define flags... foo = compflag.String("foo", "", "") bar = flag.String("bar", "", "") ) func main() { complete.CommandLine() flag.Parse() // Main function. }
Index ¶
- Variables
- func Bool(name string, value bool, usage string, options ...predict.Option) *bool
- func BoolVar(v *bool, name string, value bool, usage string, options ...predict.Option)
- func Duration(name string, value time.Duration, usage string, options ...predict.Option) *time.Duration
- func DurationVar(v *time.Duration, name string, value time.Duration, usage string, ...)
- func Int(name string, value int, usage string, options ...predict.Option) *int
- func IntVar(v *int, name string, value int, usage string, options ...predict.Option)
- func Parse()
- func String(name string, value string, usage string, options ...predict.Option) *string
- func StringVar(v *string, name string, value string, usage string, options ...predict.Option)
- type FlagSet
- func (fs *FlagSet) Arg(i int) string
- func (fs *FlagSet) Args() []string
- func (fs *FlagSet) Bool(name string, value bool, usage string, options ...predict.Option) *bool
- func (fs *FlagSet) BoolVar(p *bool, name string, value bool, usage string, options ...predict.Option)
- func (fs *FlagSet) Complete()
- func (fs *FlagSet) Duration(name string, value time.Duration, usage string, options ...predict.Option) *time.Duration
- func (fs *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string, ...)
- func (fs *FlagSet) Int(name string, value int, usage string, options ...predict.Option) *int
- func (fs *FlagSet) IntVar(p *int, name string, value int, usage string, options ...predict.Option)
- func (fs *FlagSet) Lookup(name string) *flag.Flag
- func (fs *FlagSet) NArg() int
- func (fs *FlagSet) NFlag() int
- func (fs *FlagSet) Name() string
- func (fs *FlagSet) Parse(args []string) error
- func (fs *FlagSet) Parsed() bool
- func (fs *FlagSet) PrintDefaults()
- func (fs *FlagSet) String(name string, value string, usage string, options ...predict.Option) *string
- func (fs *FlagSet) StringVar(p *string, name string, value string, usage string, options ...predict.Option)
- func (fs *FlagSet) Visit(fn func(*flag.Flag))
- func (fs *FlagSet) VisitAll(fn func(*flag.Flag))
Constants ¶
This section is empty.
Variables ¶
var CommandLine = (*FlagSet)(flag.CommandLine)
Functions ¶
func Duration ¶
func Duration(name string, value time.Duration, usage string, options ...predict.Option) *time.Duration
Duration if a flag function for a flag of type time.Duration.
func DurationVar ¶
func DurationVar(v *time.Duration, name string, value time.Duration, usage string, options ...predict.Option)
DurationVar if a flag function for a flag of already exiting variable of type time.Duration.
func Parse ¶
func Parse()
Parse parses command line arguments. It also performs bash completion when needed.
Types ¶
type FlagSet ¶
FlagSet is bash completion enabled flag.FlagSet.
func (*FlagSet) BoolVar ¶
func (fs *FlagSet) BoolVar(p *bool, name string, value bool, usage string, options ...predict.Option)
BoolVar if a flag function for a flag of already exiting variable of type bool.
func (*FlagSet) Complete ¶
func (fs *FlagSet) Complete()
Complete performs bash completion if needed.
func (*FlagSet) Duration ¶
func (fs *FlagSet) Duration(name string, value time.Duration, usage string, options ...predict.Option) *time.Duration
Duration if a flag function for a flag of type time.Duration.
func (*FlagSet) DurationVar ¶
func (fs *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string, options ...predict.Option)
DurationVar if a flag function for a flag of already exiting variable of type time.Duration.
func (*FlagSet) IntVar ¶
IntVar if a flag function for a flag of already exiting variable of type int.
func (*FlagSet) PrintDefaults ¶
func (fs *FlagSet) PrintDefaults()
func (*FlagSet) String ¶
func (fs *FlagSet) String(name string, value string, usage string, options ...predict.Option) *string
String if a flag function for a flag of type string.