cleo

package module
v0.0.0-...-949830e Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ErrNoCommand  = stringErr("no command specified")
	ErrNoCommands = stringErr("no commands registered")
)

Variables

This section is empty.

Functions

func Exit

func Exit(cmd plugins.Stdioer, code int, err error)

Exit will print the usage information for the command to the given Stderr. If the cmd.ExitFn is set, it will be called with the given exit code. Otherwise, os.Exit will be called.

Types

type Cmd

type Cmd struct {
	iox.IO // IO to be used by the command
	fs.FS  // FS to be used by the command

	Aliases  []string             // Aliases for the command
	Commands map[string]Commander // Sub commands for the command
	Feeder   plugins.FeederFn     // Plugins for the command
	Name     string               // Name of the command

	Desc string // Description of the command

	ExitFn func(int) error // ExitFn is used by the Exit method.
	// contains filtered or unexported fields
}

func (*Cmd) CmdAliases

func (cmd *Cmd) CmdAliases() []string

CmdAliases returns the aliases for the command.

func (*Cmd) CmdName

func (cmd *Cmd) CmdName() string

CmdName returns the name of the command.

func (*Cmd) Description

func (cmd *Cmd) Description() string

func (*Cmd) Exit

func (cmd *Cmd) Exit(code int) error

func (*Cmd) FileSystem

func (cmd *Cmd) FileSystem() (fs.FS, error)

func (*Cmd) Init

func (cmd *Cmd) Init() error

Init will initialize the command. It should be called before the command is used.

func (*Cmd) Main

func (cmd *Cmd) Main(ctx context.Context, pwd string, args []string) error

Main is the main entry point for the command. NEEDS TO BE IMPLEMENTED

func (*Cmd) MarshalJSON

func (cmd *Cmd) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON representation of the command.

func (*Cmd) PluginFeeder

func (cmd *Cmd) PluginFeeder() plugins.FeederFn

Plugins will provider a single FeederFn that will return all of the plugins that are available to the command.

func (*Cmd) PluginName

func (cmd *Cmd) PluginName() string

PluginName returns name of the plugin.

func (*Cmd) ScopedPlugins

func (cmd *Cmd) ScopedPlugins() plugins.Plugins

ScopedPlugins returns the plugins scoped to the command. If the plugins include the current command, it will be removed from the returned list.

func (*Cmd) SetFileSystem

func (cmd *Cmd) SetFileSystem(cab fs.FS) error

func (*Cmd) SetStdio

func (cmd *Cmd) SetStdio(oi iox.IO) error

func (*Cmd) Stdio

func (cmd *Cmd) Stdio() iox.IO

func (*Cmd) String

func (cmd *Cmd) String() string

String returns a string representation of the command.

func (*Cmd) SubCommands

func (cmd *Cmd) SubCommands() []Commander

SubCommands returns the sub-commands for the command.

type Commander

type Commander = plugcmd.Commander

type Env

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

func (*Env) Get

func (e *Env) Get(key string) string

func (*Env) Set

func (e *Env) Set(key, value string)

type ErrUnknownCommand

type ErrUnknownCommand string

func (ErrUnknownCommand) Error

func (e ErrUnknownCommand) Error() string

type Exiter

type Exiter interface {
	// plugins.Stdioer
	plugins.Plugin
	Exit(code int) error
}

Jump to

Keyboard shortcuts

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