subcommands

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: ISC Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeRPC

func DecodeRPC(decoder *msgpack.Decoder) ([]string, map[string]string, []byte, error)

Decode extracts the request encoded by Encode(). It returns the name of the RPC and the raw bytes of the request. The raw bytes can be used by the caller to unmarshal the bytes with the correct struct.

func EncodeRPC

func EncodeRPC(encoder *msgpack.Encoder, name []string, cmd Subcommand, storeConfig map[string]string) error

Encode marshals the RPC into the msgpack encoder. It prefixes the RPC with the Name() of the RPC. This is used to identify the RPC on decoding.

func List

func List() [][]string

func Register

func Register(factory CmdFactory, flags CommandFlags, args ...string)

Types

type CmdFactory

type CmdFactory func() Subcommand

type CommandFlags

type CommandFlags uint32
const (
	NeedRepositoryKey CommandFlags = 1 << iota
	BeforeRepositoryWithStorage
	BeforeRepositoryOpen
	AgentSupport
	IgnoreVersion
)

type Subcommand

type Subcommand interface {
	Parse(ctx *appcontext.AppContext, args []string) error
	Execute(ctx *appcontext.AppContext, repo *repository.Repository) (int, error)
	GetRepositorySecret() []byte
	GetFlags() CommandFlags

	GetCWD() string
	SetCWD(string)
	GetCommandLine() string
	SetCommandLine(string)

	GetLogInfo() bool
	SetLogInfo(bool)
	GetLogTraces() string
	SetLogTraces(string)
	// contains filtered or unexported methods
}

func Lookup

func Lookup(arguments []string) (Subcommand, []string, []string)

type SubcommandBase

type SubcommandBase struct {
	RepositorySecret []byte
	Flags            CommandFlags
	CWD              string
	CommandLine      string

	// XXX - rework that post-release
	LogInfo   bool
	LogTraces string
}

func (*SubcommandBase) GetCWD

func (cmd *SubcommandBase) GetCWD() string

func (*SubcommandBase) GetCommandLine

func (cmd *SubcommandBase) GetCommandLine() string

func (*SubcommandBase) GetFlags

func (cmd *SubcommandBase) GetFlags() CommandFlags

func (*SubcommandBase) GetLogInfo

func (cmd *SubcommandBase) GetLogInfo() bool

func (*SubcommandBase) GetLogTraces

func (cmd *SubcommandBase) GetLogTraces() string

func (*SubcommandBase) GetRepositorySecret

func (cmd *SubcommandBase) GetRepositorySecret() []byte

func (*SubcommandBase) SetCWD

func (cmd *SubcommandBase) SetCWD(cwd string)

func (*SubcommandBase) SetCommandLine

func (cmd *SubcommandBase) SetCommandLine(cmdline string)

func (*SubcommandBase) SetLogInfo

func (cmd *SubcommandBase) SetLogInfo(v bool)

func (*SubcommandBase) SetLogTraces

func (cmd *SubcommandBase) SetLogTraces(traces string)

Jump to

Keyboard shortcuts

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