commands

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Application

func Application(opts ...Option) *cobra.Command

Application returns a new application command.

func Devices

func Devices(opts ...Option) *cobra.Command

Devices returns a new devices command.

func ExecuteParentPersistentPostRun

func ExecuteParentPersistentPostRun(cmd *cobra.Command, args []string) error

ExecuteParentPersistentPostRun executes cmd's parent's PersistentPostRunE or PersistentPostRun.

func ExecuteParentPersistentPreRun

func ExecuteParentPersistentPreRun(cmd *cobra.Command, args []string) error

ExecuteParentPersistentPreRun executes cmd's parent's PersistentPreRunE or PersistentPreRun.

func Export

func Export(cmd *cobra.Command, args []string, f func(s source.Source, item string) error) error

func New

func New(opts ...Option) *cobra.Command

New returns a new command.

func Source

func Source(sourceName, short string, opts ...SourceOptions) *cobra.Command

Source returns a new source command.

Types

type CobraRun

type CobraRun func(cmd *cobra.Command, args []string)

type CobraRunE

type CobraRunE func(cmd *cobra.Command, args []string) error

func ExportApplication

func ExportApplication() CobraRunE

func ExportDevices

func ExportDevices() CobraRunE

func SourcePersistentPreRunE

func SourcePersistentPreRunE() CobraRunE

SourcePersistentPreRunE returns a new function that sets the active source.

type Iterator

type Iterator interface {
	// Next returns the next item from the iterator. io.EOF is returned when no more items are left.
	Next() (item string, err error)
}

Iterator returns items

func NewListIterator

func NewListIterator(items []string) Iterator

NewListIterator returns a new iterator from a list of items.

func NewReaderIterator

func NewReaderIterator(rd io.Reader, sep byte) Iterator

NewReaderIterator returns a new iterator from a reader.

type Option

type Option func(*cobra.Command)

Option allows extending the command when it is instantiated with New.

func WithAliases

func WithAliases(a []string) Option

WithAliases returns an option that sets the command's Aliases field.

func WithFlagSet

func WithFlagSet(fs *pflag.FlagSet) Option

WithFlagSet returns an option that adds a flag set to the command's flags.

func WithGroupID

func WithGroupID(id string) Option

WithGroupID returns an option that sets the command's GroupID field.

func WithPersistentPostRun

func WithPersistentPostRun(f CobraRun) Option

WithPersistentPostRun returns an option that sets the command's PersistentPostRun field.

func WithPersistentPostRunE

func WithPersistentPostRunE(f CobraRunE) Option

WithPersistentPostRunE returns an option that sets the command's PersistentPostRunE field.

func WithPersistentPreRun

func WithPersistentPreRun(f CobraRun) Option

WithPersistentPreRun returns an option that sets the command's PersistentPreRun field.

func WithPersistentPreRunE

func WithPersistentPreRunE(f CobraRunE) Option

WithPersistentPreRunE returns an option that sets the command's PersistentPreRunE field.

func WithPostRun

func WithPostRun(f CobraRun) Option

WithPostRun returns an option that sets the command's PostRun field.

func WithPostRunE

func WithPostRunE(f CobraRunE) Option

WithPostRunE returns an option that sets the command's PostRunE field.

func WithPreRun

func WithPreRun(f CobraRun) Option

WithPreRun returns an option that sets the command's PreRun field.

func WithPreRunE

func WithPreRunE(f CobraRunE) Option

WithPreRunE returns an option that sets the command's PreRunE field.

func WithRun

func WithRun(f CobraRun) Option

WithRun returns an option that sets the command's Run field.

func WithRunE

func WithRunE(f CobraRunE) Option

WithRunE returns an option that sets the command's RunE field.

func WithShort

func WithShort(s string) Option

WithShort returns an option that sets the command's Short field.

func WithSubcommands

func WithSubcommands(cmd ...*cobra.Command) Option

WithSubcommands returns an option that adds commands cmd to the command.

func WithUse

func WithUse(s string) Option

WithUse returns an option that sets the command's Use field.

type SourceOptions

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

func WithApplicationOptions

func WithApplicationOptions(opts ...Option) SourceOptions

WithApplicationOptions returns SourceOptions with appOpts field set to opts.

func WithDevicesOptions

func WithDevicesOptions(opts ...Option) SourceOptions

WithDevicesOptions returns SourceOptions with devOpts field set to opts.

func WithSourceOptions

func WithSourceOptions(opts ...Option) SourceOptions

WithSourceOptions returns SourceOptions with opts field set to opts.

func (*SourceOptions) Extend

func (s *SourceOptions) Extend(src SourceOptions)

Extend merges respectable fields from src into s.

Jump to

Keyboard shortcuts

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