compflag

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var CommandLine = (*FlagSet)(flag.CommandLine)

Functions

func Bool

func Bool(name string, value bool, usage string, options ...predict.Option) *bool

Bool if a flag function for a flag of type bool.

func BoolVar

func BoolVar(v *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 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 Int

func Int(name string, value int, usage string, options ...predict.Option) *int

Int if a flag function for a flag of type int.

func IntVar

func IntVar(v *int, name string, value int, usage string, options ...predict.Option)

IntVar if a flag function for a flag of already exiting variable of type int.

func Parse

func Parse()

Parse parses command line arguments. It also performs bash completion when needed.

func String

func String(name string, value string, usage string, options ...predict.Option) *string

String if a flag function for a flag of type string.

func StringVar

func StringVar(v *string, name string, value string, usage string, options ...predict.Option)

StringVar if a flag function for a flag of already exiting variable of type string.

Types

type FlagSet

type FlagSet flag.FlagSet

FlagSet is bash completion enabled flag.FlagSet.

func (*FlagSet) Arg

func (fs *FlagSet) Arg(i int) string

func (*FlagSet) Args

func (fs *FlagSet) Args() []string

func (*FlagSet) Bool

func (fs *FlagSet) Bool(name string, value bool, usage string, options ...predict.Option) *bool

Bool if a flag function for a flag of type bool.

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) Int

func (fs *FlagSet) Int(name string, value int, usage string, options ...predict.Option) *int

Int if a flag function for a flag of type int.

func (*FlagSet) IntVar

func (fs *FlagSet) IntVar(p *int, name string, value int, usage string, options ...predict.Option)

IntVar if a flag function for a flag of already exiting variable of type int.

func (*FlagSet) Lookup

func (fs *FlagSet) Lookup(name string) *flag.Flag

func (*FlagSet) NArg

func (fs *FlagSet) NArg() int

func (*FlagSet) NFlag

func (fs *FlagSet) NFlag() int

func (*FlagSet) Name

func (fs *FlagSet) Name() string

func (*FlagSet) Parse

func (fs *FlagSet) Parse(args []string) error

Parse parses command line arguments.

func (*FlagSet) Parsed

func (fs *FlagSet) Parsed() bool

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.

func (*FlagSet) StringVar

func (fs *FlagSet) StringVar(p *string, name string, value string, usage string, options ...predict.Option)

StringVar if a flag function for a flag of already exiting variable of type string.

func (*FlagSet) Visit

func (fs *FlagSet) Visit(fn func(*flag.Flag))

func (*FlagSet) VisitAll

func (fs *FlagSet) VisitAll(fn func(*flag.Flag))

Directories

Path Synopsis
Generates flags.go.
Generates flags.go.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL