cli

package
v0.0.0-...-c474f48 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2022 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHandler

func AddHandler(pattern string, groups FlagGroups, callback func(Context), desc string)

func Handle

func Handle(args []string) bool

func SetHandlers

func SetHandlers(h []*Handler)

Types

type Arguments

type Arguments map[string]interface{}

func (Arguments) Bool

func (self Arguments) Bool(key string) bool

func (Arguments) Int64

func (self Arguments) Int64(key string) int64

func (Arguments) String

func (self Arguments) String(key string) string

func (Arguments) StringSlice

func (self Arguments) StringSlice(key string) []string

type BoolFlag

type BoolFlag struct {
	Patterns     []string
	Name         string
	Description  string
	DefaultValue bool
	OmitValue    bool
}

func (BoolFlag) GetDescription

func (self BoolFlag) GetDescription() string

func (BoolFlag) GetName

func (self BoolFlag) GetName() string

func (BoolFlag) GetParser

func (self BoolFlag) GetParser() Parser

func (BoolFlag) GetPatterns

func (self BoolFlag) GetPatterns() []string

type BoolFlagParser

type BoolFlagParser struct {
	// contains filtered or unexported fields
}

func (BoolFlagParser) Capture

func (self BoolFlagParser) Capture(values []string) ([]string, map[string]interface{})

func (BoolFlagParser) Match

func (self BoolFlagParser) Match(values []string) ([]string, bool)

func (BoolFlagParser) String

func (self BoolFlagParser) String() string

type CaptureGroupParser

type CaptureGroupParser struct {
	// contains filtered or unexported fields
}

func (CaptureGroupParser) Capture

func (self CaptureGroupParser) Capture(values []string) ([]string, map[string]interface{})

func (CaptureGroupParser) Match

func (self CaptureGroupParser) Match(values []string) ([]string, bool)

func (CaptureGroupParser) String

func (self CaptureGroupParser) String() string

type CompleteParser

type CompleteParser struct {
	// contains filtered or unexported fields
}

func (CompleteParser) Capture

func (self CompleteParser) Capture(values []string) ([]string, map[string]interface{})

func (CompleteParser) Match

func (self CompleteParser) Match(values []string) ([]string, bool)

func (CompleteParser) String

func (self CompleteParser) String() string

type Context

type Context struct {
	// contains filtered or unexported fields
}

func (Context) Args

func (self Context) Args() Arguments

func (Context) Handlers

func (self Context) Handlers() []*Handler

type EqualParser

type EqualParser struct {
	// contains filtered or unexported fields
}

func (EqualParser) Capture

func (self EqualParser) Capture(values []string) ([]string, map[string]interface{})

func (EqualParser) Match

func (self EqualParser) Match(values []string) ([]string, bool)

func (EqualParser) String

func (self EqualParser) String() string

type Flag

type Flag interface {
	GetPatterns() []string
	GetName() string
	GetDescription() string
	GetParser() Parser
}

type FlagGroup

type FlagGroup struct {
	Name  string
	Flags []Flag
}

func NewFlagGroup

func NewFlagGroup(name string, flags ...Flag) FlagGroup

type FlagGroups

type FlagGroups []FlagGroup

type FlagParser

type FlagParser struct {
	// contains filtered or unexported fields
}

func (FlagParser) Capture

func (self FlagParser) Capture(values []string) ([]string, map[string]interface{})

func (FlagParser) Match

func (self FlagParser) Match(values []string) ([]string, bool)

func (FlagParser) String

func (self FlagParser) String() string

type Handler

type Handler struct {
	Pattern     string
	FlagGroups  FlagGroups
	Callback    func(Context)
	Description string
}

func (*Handler) SplitPattern

func (self *Handler) SplitPattern() []string

Split on spaces but ignore spaces inside <...> and [...]

type IntFlag

type IntFlag struct {
	Patterns     []string
	Name         string
	Description  string
	DefaultValue int64
}

func (IntFlag) GetDescription

func (self IntFlag) GetDescription() string

func (IntFlag) GetName

func (self IntFlag) GetName() string

func (IntFlag) GetParser

func (self IntFlag) GetParser() Parser

func (IntFlag) GetPatterns

func (self IntFlag) GetPatterns() []string

type IntFlagParser

type IntFlagParser struct {
	// contains filtered or unexported fields
}

func (IntFlagParser) Capture

func (self IntFlagParser) Capture(values []string) ([]string, map[string]interface{})

func (IntFlagParser) Match

func (self IntFlagParser) Match(values []string) ([]string, bool)

func (IntFlagParser) String

func (self IntFlagParser) String() string

type Parser

type Parser interface {
	Match([]string) ([]string, bool)
	Capture([]string) ([]string, map[string]interface{})
}

type ShortCircuitParser

type ShortCircuitParser struct {
	// contains filtered or unexported fields
}

func (ShortCircuitParser) Capture

func (self ShortCircuitParser) Capture(values []string) ([]string, map[string]interface{})

func (ShortCircuitParser) Match

func (self ShortCircuitParser) Match(values []string) ([]string, bool)

func (ShortCircuitParser) String

func (self ShortCircuitParser) String() string

type StringFlag

type StringFlag struct {
	Patterns     []string
	Name         string
	Description  string
	DefaultValue string
}

func (StringFlag) GetDescription

func (self StringFlag) GetDescription() string

func (StringFlag) GetName

func (self StringFlag) GetName() string

func (StringFlag) GetParser

func (self StringFlag) GetParser() Parser

func (StringFlag) GetPatterns

func (self StringFlag) GetPatterns() []string

type StringFlagParser

type StringFlagParser struct {
	// contains filtered or unexported fields
}

func (StringFlagParser) Capture

func (self StringFlagParser) Capture(values []string) ([]string, map[string]interface{})

func (StringFlagParser) Match

func (self StringFlagParser) Match(values []string) ([]string, bool)

func (StringFlagParser) String

func (self StringFlagParser) String() string

type StringSliceFlag

type StringSliceFlag struct {
	Patterns     []string
	Name         string
	Description  string
	DefaultValue []string
}

func (StringSliceFlag) GetDescription

func (self StringSliceFlag) GetDescription() string

func (StringSliceFlag) GetName

func (self StringSliceFlag) GetName() string

func (StringSliceFlag) GetParser

func (self StringSliceFlag) GetParser() Parser

func (StringSliceFlag) GetPatterns

func (self StringSliceFlag) GetPatterns() []string

type StringSliceFlagParser

type StringSliceFlagParser struct {
	// contains filtered or unexported fields
}

func (StringSliceFlagParser) Capture

func (self StringSliceFlagParser) Capture(values []string) ([]string, map[string]interface{})

func (StringSliceFlagParser) Match

func (self StringSliceFlagParser) Match(values []string) ([]string, bool)

func (StringSliceFlagParser) String

func (self StringSliceFlagParser) String() string

Jump to

Keyboard shortcuts

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