ngsicli

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NonCondition = iota
	NandCondition
	XnorCondition
)

Variables

View Source
var (
	SyslogFlag = &StringFlag{
		Name:    "syslog",
		Usage:   "syslog logging `LEVEL` (off, err, info, debug)",
		Choices: []string{"off", "err", "info", "debug"},
	}
	StderrFlag = &StringFlag{
		Name:    "stderr",
		Usage:   "stderr logging `LEVEL` (err, info, debug)",
		Choices: []string{"off", "err", "info", "debug"},
	}
	ConfigDirFlag = &StringFlag{
		Name:  "configDir",
		Usage: "configuration `DIR` name",
	}
	ConfigFlag = &StringFlag{
		Name:  "config",
		Usage: "configuration `FILE` name",
	}
	CacheFlag = &StringFlag{
		Name:  "cache",
		Usage: "cache `FILE` name",
	}
	HelpFlag = &BoolFlag{
		Name:  "help",
		Usage: "show help",
	}
	MarginFlag = &Int64Flag{
		Name:   "margin",
		Usage:  "I/O time out (second)",
		Hidden: true,
		Value:  180,
	}
	TimeOutFlag = &Int64Flag{
		Name:   "timeout",
		Usage:  "I/O time out (second)",
		Hidden: true,
		Value:  60,
	}
	MaxCountFlag = &Int64Flag{
		Name:   "maxCount",
		Usage:  "maxCount",
		Hidden: true,
		Value:  100,
	}
	BatchFlag = &BoolFlag{
		Name:    "batch",
		Aliases: []string{"B"},
		Usage:   "don't use previous args (batch)",
	}
	CmdNameFlag = &StringFlag{
		Name:   "cmdName",
		Hidden: true,
	}
	InsecureSkipVerifyFlag = &BoolFlag{
		Name:  "insecureSkipVerify",
		Usage: "TLS/SSL skip certificate verification",
	}
)

Global Flags

View Source
var (
	HostRFlag = &StringFlag{
		Name:         "host",
		Usage:        "broker or server host `VALUE`",
		Aliases:      []string{"h"},
		Required:     true,
		InitClient:   true,
		PreviousArgs: true,
	}
	HostFlag = &StringFlag{
		Name:    "host",
		Usage:   "broker or server host `VALUE`",
		Aliases: []string{"h"},
	}
	TenantFlag = &StringFlag{
		Name:       "service",
		Aliases:    []string{"s"},
		Usage:      "FIWARE Service `VALUE`",
		ValueEmpty: true,
	}
	ScopeFlag = &StringFlag{
		Name:       "path",
		Aliases:    []string{"p"},
		Usage:      "FIWARE ServicePath `VALUE`",
		ValueEmpty: true,
	}
	OAuthTokenFlag = &StringFlag{
		Name:       "oAuthToken",
		Usage:      "OAuth token `VALUE`",
		Hidden:     true,
		ValueEmpty: true,
	}
	XAuthTokenFlag = &BoolFlag{
		Name:   "xAuthToken",
		Usage:  "use X-Auth-Token",
		Hidden: true,
	}
)
View Source
var (
	SafeStringFlag = &StringFlag{
		Name:  "safeString",
		Usage: "use safe string (`VALUE`: on/off)",
	}
	NgsiTypeFlag = &StringFlag{
		Name:  "ngsiType",
		Usage: "NGSI type: v2 or ld",
	}
)
View Source
var (
	VerboseFlag = &BoolFlag{
		Name:    "verbose",
		Aliases: []string{"v"},
		Usage:   "verbose",
	}
	JsonFlag = &BoolFlag{
		Name:    "json",
		Aliases: []string{"j"},
		Usage:   "JSON format",
	}
	PrettyFlag = &BoolFlag{
		Name:    "pretty",
		Aliases: []string{"P"},
		Value:   false,
		Usage:   "pretty format",
	}
	RunFlag = &BoolFlag{
		Name:  "run",
		Usage: "run command",
		Value: false,
	}
)
View Source
var (
	Version  string
	Revision string
)
View Source
var CmdMode = ""
View Source
var Copyright string

Functions

func InitCmd

func InitCmd(c *Context) (*ngsilib.NGSI, error)

func NewClient

func NewClient(ngsi *ngsilib.NGSI, c *Context, isHTTPVerb bool, serverList []string) (*ngsilib.Client, error)

func NewClientSkipGetToken

func NewClientSkipGetToken(ngsi *ngsilib.NGSI, c *Context, isHTTPVerb bool, serverList []string) (*ngsilib.Client, error)

func ParseOptions

func ParseOptions(c *Context, args []string, opts []string) *url.Values

Types

type ActionFunc

type ActionFunc func(*Context, *ngsilib.NGSI, *ngsilib.Client) error

type App

type App struct {
	Name        string
	HelpName    string
	Usage       string
	UsageText   string
	ArgsUsage   string
	Version     string
	Description string
	Commands    []*Command
	Flags       []Flag
	Compiled    time.Time
	Copyright   string
}

func (*App) Parse

func (r *App) Parse(args []string) (*Command, *Context, error)

func (*App) Run

func (r *App) Run(args []string) error

type Args

type Args interface {
	Get(n int) string
	Len() int
}

type BoolFlag

type BoolFlag struct {
	Name     string
	Aliases  []string
	Usage    string
	Value    bool
	Hidden   bool
	Set      bool
	Required bool
}

func (*BoolFlag) AllowEmpty

func (f *BoolFlag) AllowEmpty() bool

func (*BoolFlag) Check

func (f *BoolFlag) Check(name, alias string) bool

func (*BoolFlag) Copy

func (f *BoolFlag) Copy(reset bool) Flag

func (*BoolFlag) FlagAliases

func (f *BoolFlag) FlagAliases() []string

func (*BoolFlag) FlagHidden

func (f *BoolFlag) FlagHidden() bool

func (*BoolFlag) FlagName

func (f *BoolFlag) FlagName() string

func (*BoolFlag) FlagNameList

func (f *BoolFlag) FlagNameList() string

func (*BoolFlag) FlagUsage

func (f *BoolFlag) FlagUsage() string

func (*BoolFlag) IsInitClient

func (f *BoolFlag) IsInitClient() bool

func (*BoolFlag) IsRequired

func (f *BoolFlag) IsRequired() bool

func (*BoolFlag) IsSet

func (f *BoolFlag) IsSet() bool

func (*BoolFlag) SetValue

func (f *BoolFlag) SetValue(v interface{}) error

type Command

type Command struct {
	Name          string
	Aliases       []string
	Usage         string
	UsageText     string
	Description   string
	ArgsUsage     string
	Category      string
	Subcommands   []*Command
	Flags         []Flag
	RequiredFlags []string
	OptionFlags   *ValidationFlag
	ServerList    []string
	Hidden        bool

	Action ActionFunc
}

type Context

type Context struct {
	App            *App
	Ngsi           *ngsilib.NGSI
	Client         *ngsilib.Client
	Client2        *ngsilib.Client
	Flags          []Flag
	GlobalFlags    []Flag
	RequiredFlags  []string
	Arg            *cmdArgs
	Commands       []*Command
	ServerList     []string
	CommandName    string
	HelpCommand    bool
	Bashcompletion bool
}

func NewContext

func NewContext(r *App) *Context

func (*Context) Args

func (c *Context) Args() Args

func (*Context) Bool

func (c *Context) Bool(flag string) bool

func (*Context) FlagNames

func (c *Context) FlagNames() []string

func (*Context) GetFlag

func (c *Context) GetFlag(name string) Flag

func (*Context) GetStringFlag

func (c *Context) GetStringFlag(name string) *StringFlag

func (*Context) HasFlag

func (c *Context) HasFlag(name string) bool

func (*Context) Int64

func (c *Context) Int64(flag string) int64

func (*Context) IsRequired

func (c *Context) IsRequired(name string) bool

func (*Context) IsSet

func (c *Context) IsSet(flag string) bool

func (*Context) IsSetAND

func (c *Context) IsSetAND(params []string) bool

func (*Context) IsSetOR

func (c *Context) IsSetOR(params []string) bool

func (*Context) String

func (c *Context) String(flag string) string

type Flag

type Flag interface {
	FlagName() string
	FlagNameList() string
	FlagAliases() []string
	FlagUsage() string
	FlagHidden() bool
	Check(name, alias string) bool
	IsSet() bool
	IsRequired() bool
	IsInitClient() bool
	Copy(reset bool) Flag
	SetValue(v interface{}) error
	AllowEmpty() bool
}

type Int64Flag

type Int64Flag struct {
	Name     string
	Aliases  []string
	Usage    string
	Value    int64
	Hidden   bool
	Set      bool
	Required bool
}

func (*Int64Flag) AllowEmpty

func (f *Int64Flag) AllowEmpty() bool

func (*Int64Flag) Check

func (f *Int64Flag) Check(name, alias string) bool

func (*Int64Flag) Copy

func (f *Int64Flag) Copy(reset bool) Flag

Copy Flag

func (*Int64Flag) FlagAliases

func (f *Int64Flag) FlagAliases() []string

func (*Int64Flag) FlagHidden

func (f *Int64Flag) FlagHidden() bool

func (*Int64Flag) FlagName

func (f *Int64Flag) FlagName() string

func (*Int64Flag) FlagNameList

func (f *Int64Flag) FlagNameList() string

func (*Int64Flag) FlagUsage

func (f *Int64Flag) FlagUsage() string

func (*Int64Flag) IsInitClient

func (f *Int64Flag) IsInitClient() bool

func (*Int64Flag) IsRequired

func (f *Int64Flag) IsRequired() bool

func (*Int64Flag) IsSet

func (f *Int64Flag) IsSet() bool

func (*Int64Flag) SetValue

func (f *Int64Flag) SetValue(v interface{}) error

Set Valut to Flag

type StringFlag

type StringFlag struct {
	Name         string
	Aliases      []string
	Usage        string
	Value        string
	Hidden       bool
	Set          bool
	Required     bool
	InitClient   bool
	SkipGetToken bool
	ValueEmpty   bool
	PreviousArgs bool
	SkipRefHost  bool
	Choices      []string
}

func (*StringFlag) AllowEmpty

func (f *StringFlag) AllowEmpty() bool

func (*StringFlag) Check

func (f *StringFlag) Check(name, alias string) bool

func (*StringFlag) Copy

func (f *StringFlag) Copy(reset bool) Flag

func (*StringFlag) FlagAliases

func (f *StringFlag) FlagAliases() []string

func (*StringFlag) FlagHidden

func (f *StringFlag) FlagHidden() bool

func (*StringFlag) FlagName

func (f *StringFlag) FlagName() string

func (*StringFlag) FlagNameList

func (f *StringFlag) FlagNameList() string

func (*StringFlag) FlagUsage

func (f *StringFlag) FlagUsage() string

func (*StringFlag) IsInitClient

func (f *StringFlag) IsInitClient() bool

func (*StringFlag) IsRequired

func (f *StringFlag) IsRequired() bool

func (*StringFlag) IsSet

func (f *StringFlag) IsSet() bool

func (*StringFlag) SetValue

func (f *StringFlag) SetValue(v interface{}) error

type ValidationFlag

type ValidationFlag struct {
	Mode  int
	Flags []string
}

Jump to

Keyboard shortcuts

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