easycomp

package module
v0.0.0-...-7bec4bd Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2018 License: MIT Imports: 13 Imported by: 0

README

easycomp

Generate shell completion script with golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument interface {
	Children() []Argument
	Complete([]string) []string
	Match([]string) bool
	String() string
}

func Nest

func Nest(arg Argument, depth int) Argument

type Arguments

type Arguments []Argument

func (*Arguments) Append

func (a *Arguments) Append(arg Argument)

func (*Arguments) Children

func (a *Arguments) Children() []Argument

func (*Arguments) Complete

func (a *Arguments) Complete(words []string) []string

func (*Arguments) Match

func (a *Arguments) Match(_ []string) bool

func (*Arguments) String

func (a *Arguments) String() string

type CobraCommand

type CobraCommand cobra.Command

func (*CobraCommand) Children

func (c *CobraCommand) Children() []Argument

func (*CobraCommand) Command

func (c *CobraCommand) Command() *cobra.Command

func (*CobraCommand) Complete

func (c *CobraCommand) Complete(words []string) []string

func (*CobraCommand) IsRoot

func (c *CobraCommand) IsRoot() bool

func (*CobraCommand) Match

func (c *CobraCommand) Match(words []string) bool

func (*CobraCommand) Name

func (c *CobraCommand) Name() string

func (*CobraCommand) String

func (c *CobraCommand) String() string

type CommandLine

type CommandLine struct {
	Arguments
	// contains filtered or unexported fields
}

func AddCobraCommand

func AddCobraCommand(rootCmd *cobra.Command, name string) *CommandLine

func AddFlag

func AddFlag(flagSet *flag.FlagSet, name, desc string) *CommandLine

func (*CommandLine) Complete

func (c *CommandLine) Complete(words []string) []string

func (*CommandLine) IsBoolFlag

func (c *CommandLine) IsBoolFlag() bool

func (*CommandLine) Set

func (c *CommandLine) Set(_ string) error

func (*CommandLine) String

func (c *CommandLine) String() string

func (*CommandLine) Type

func (c *CommandLine) Type() string

type Condition

type Condition struct {
	Argument
	// contains filtered or unexported fields
}

func NewCondition

func NewCondition(arg Argument, match func([]string) bool) *Condition

func (*Condition) Match

func (c *Condition) Match(words []string) bool

type Flag

type Flag struct {
	*flag.Flag
	// contains filtered or unexported fields
}

func NewFlag

func NewFlag(f *flag.Flag, s *FlagSet) *Flag

func (*Flag) Children

func (f *Flag) Children() []Argument

func (*Flag) Complete

func (f *Flag) Complete(words []string) []string

func (*Flag) IsBoolFlag

func (f *Flag) IsBoolFlag() bool

func (*Flag) Match

func (f *Flag) Match(words []string) bool

func (*Flag) String

func (f *Flag) String() string

type FlagSet

type FlagSet flag.FlagSet

func (*FlagSet) Children

func (s *FlagSet) Children() []Argument

func (*FlagSet) Complete

func (s *FlagSet) Complete(words []string) []string

func (*FlagSet) Match

func (s *FlagSet) Match(words []string) bool

func (*FlagSet) String

func (s *FlagSet) String() string

type FlagValue

type FlagValue struct {
	flag.Value
	// contains filtered or unexported fields
}

func NewFlagValue

func NewFlagValue(f *Flag) *FlagValue

func (*FlagValue) Children

func (v *FlagValue) Children() []Argument

func (*FlagValue) Complete

func (v *FlagValue) Complete(words []string) []string

func (*FlagValue) Match

func (v *FlagValue) Match(words []string) bool

type PFlag

type PFlag struct {
	*pflag.Flag
	// contains filtered or unexported fields
}

func NewPFlag

func NewPFlag(f *pflag.Flag, c *CobraCommand) *PFlag

func (*PFlag) Children

func (f *PFlag) Children() []Argument

func (*PFlag) Complete

func (f *PFlag) Complete(words []string) []string

func (*PFlag) Match

func (f *PFlag) Match(words []string) bool

func (*PFlag) String

func (f *PFlag) String() string

type PFlagSet

type PFlagSet struct {
	*pflag.FlagSet
	// contains filtered or unexported fields
}

func NewPFlagSet

func NewPFlagSet(s *pflag.FlagSet, cmd *CobraCommand) *PFlagSet

func (*PFlagSet) Children

func (s *PFlagSet) Children() []Argument

func (*PFlagSet) Complete

func (s *PFlagSet) Complete(words []string) []string

func (*PFlagSet) Match

func (s *PFlagSet) Match(words []string) bool

func (*PFlagSet) String

func (s *PFlagSet) String() string

type String

type String string

func NewString

func NewString(s string) *String

func (*String) Children

func (s *String) Children() []Argument

func (*String) Complete

func (s *String) Complete(words []string) []string

func (*String) Match

func (s *String) Match(words []string) bool

func (*String) String

func (s *String) String() string

type Transform

type Transform struct {
	Argument
	// contains filtered or unexported fields
}

func NewTransform

func NewTransform(arg Argument, fn func([]string) []string) *Transform

func (*Transform) Complete

func (t *Transform) Complete(words []string) []string

func (*Transform) Match

func (t *Transform) Match(words []string) bool

func (*Transform) Transform

func (t *Transform) Transform(words []string) []string

type Tree

type Tree struct {
	Type     string
	Value    string
	Match    bool
	Children []*Tree
	Words    string
}

Jump to

Keyboard shortcuts

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