Documentation
¶
Overview ¶
Package repl provides a REPL and CLI functionality for aRPC connections.
Index ¶
- Constants
- Variables
- func AddErrSyntax(event *am.Event, mach *am.Machine, err error, args am.A) error
- func InspectingCmds(repl *Repl) []*cobra.Command
- func ListingFlags(cmd *cobra.Command)
- func MutationCmds(repl *Repl) []*cobra.Command
- func MutationFlags(repl ReplApi, cmd *cobra.Command, groupCmd bool)
- func NewRootCommand(repl *Repl, cliArgs, osArgs []string) *cobra.Command
- func ReplCmds(repl *Repl) []*cobra.Command
- func SysCmds(repl *Repl) []*cobra.Command
- func WaitingCmds(repl *Repl) []*cobra.Command
- type A
- type Args
- type CmdName
- type FlagName
- type GroupId
- type History
- type HistoryItem
- type ListFilters
- type NamedAddr
- type Repl
- func (r *Repl) AddrChangedEnter(e *am.Event) bool
- func (r *Repl) AddrChangedState(e *am.Event)
- func (r *Repl) CmdAddEnter(e *am.Event) bool
- func (r *Repl) CmdAddState(e *am.Event)
- func (r *Repl) CmdGroupAddEnter(e *am.Event) bool
- func (r *Repl) CmdGroupAddState(e *am.Event)
- func (r *Repl) CmdGroupRemoveEnter(e *am.Event) bool
- func (r *Repl) CmdGroupRemoveState(e *am.Event)
- func (r *Repl) CmdGroupSetEnter(e *am.Event) bool
- func (r *Repl) CmdGroupSetState(e *am.Event)
- func (r *Repl) CmdRemoveEnter(e *am.Event) bool
- func (r *Repl) CmdRemoveState(e *am.Event)
- func (r *Repl) CmdSetEnter(e *am.Event) bool
- func (r *Repl) CmdSetState(e *am.Event)
- func (r *Repl) ConnectedExit(e *am.Event) bool
- func (r *Repl) ConnectedFullyEnter(e *am.Event) bool
- func (r *Repl) ConnectedFullyExit(e *am.Event) bool
- func (r *Repl) ConnectedState(e *am.Event)
- func (r *Repl) ConnectingEnter(e *am.Event) bool
- func (r *Repl) ConnectingExit(e *am.Event) bool
- func (r *Repl) ConnectingState(e *am.Event)
- func (r *Repl) DisconnectedState(e *am.Event)
- func (r *Repl) DisconnectingState(e *am.Event)
- func (r *Repl) ErrNetworkState(e *am.Event)
- func (r *Repl) ListMachines(filters *ListFilters) ([]*arpc.Client, error)
- func (r *Repl) ListMachinesEnter(e *am.Event) bool
- func (r *Repl) ListMachinesState(e *am.Event)
- func (r *Repl) Machine() *am.Machine
- func (r *Repl) NetMach(machId string) *arpc.NetworkMachine
- func (r *Repl) NetMachArgs(machId string) []string
- func (r *Repl) Print(txt string, args ...any)
- func (r *Repl) PrintErr(txt string, args ...any)
- func (r *Repl) PrintMsg(txt string, args ...any)
- func (r *Repl) ReplModeState(e *am.Event)
- func (r *Repl) RpcConnEnter(e *am.Event) bool
- func (r *Repl) RpcConnState(e *am.Event)
- func (r *Repl) RpcDisconnEnter(e *am.Event) bool
- func (r *Repl) RpcDisconnState(e *am.Event)
- func (r *Repl) StartEnter(e *am.Event) bool
- func (r *Repl) StartState(e *am.Event)
- type ReplApi
- type S
- type T
Constants ¶
const APrefix = "am_repl"
Variables ¶
var ( Sp = utils.Sp Pass = am.Pass )
var ( CmdRoot = CmdName{"arpc"} CmdAdd = CmdName{"add"} CmdRemove = CmdName{"remove"} CmdSet = CmdName{"set"} CmdGroupAdd = CmdName{"group-add"} CmdGroupRemove = CmdName{"group-remove"} CmdGroupSet = CmdName{"group-set"} CmdWhen = CmdName{"when"} CmdWhenNot = CmdName{"when-not"} CmdWhenTime = CmdName{"when-time"} CmdList = CmdName{"list"} CmdMach = CmdName{"mach"} CmdTime = CmdName{"time"} CmdInspect = CmdName{"inspect"} CmdStatus = CmdName{"status"} CmdScript = CmdName{"script"} CmdExit = CmdName{"exit"} CmdCheatsheet = CmdName{"cheatsheet"} CmdConnect = CmdName{"connect"} CmdNames = enum.New(CmdRoot, CmdAdd, CmdRemove, CmdSet, CmdGroupAdd, CmdGroupRemove, CmdGroupSet, CmdWhen, CmdWhenNot, CmdWhenTime, CmdList, CmdMach, CmdTime, CmdInspect, CmdStatus, CmdScript, CmdExit, CmdCheatsheet, CmdConnect) )
var ( // CLI flags (root command) FlagCliFile = FlagName{"file"} FlagCliFileShort = FlagName{"f"} FlagCliDir = FlagName{"dir"} FlagCliDirShort = FlagName{"d"} FlagCliWatch = FlagName{"watch"} FlagCliWatchShort = FlagName{"w"} FlagCliAmDbgAddr = FlagName{"am-dbg-addr"} FlagCliLogLevel = FlagName{"log-level"} FlagCliLivepage = FlagName{"livepage"} FlagCliLivepageAddr = FlagName{"livepage-addr"} FlagCliReqAll = FlagName{"req-all"} FlagCliReqAllShort = FlagName{"a"} // mutations FlagArg = FlagName{"arg"} FlagVal = FlagName{"val"} // listing FlagActive = FlagName{"active"} FlagActiveShort = FlagName{"a"} FlagInactive = FlagName{"inactive"} FlagInactiveShort = FlagName{"i"} FlagMtimeStates = FlagName{"mtime-states"} FlagMtimeStatesShort = FlagName{"m"} FlagMtimeMin = FlagName{"mtime-min"} FlagMtimeMinShort = FlagName{"t"} FlagMtimeMax = FlagName{"mtime-max"} FlagMtimeMaxShort = FlagName{"T"} FlagParent = FlagName{"parent"} FlagParentShort = FlagName{"P"} FlagIdRegexp = FlagName{"id-regexp"} FlagIdRegexpShort = FlagName{"r"} FlagIdPartial = FlagName{"id-partial"} FlagIdPartialShort = FlagName{"I"} FlagIdPrefix = FlagName{"id-prefix"} FlagIdPrefixShort = FlagName{"p"} FlagIdSuffix = FlagName{"id-suffix"} FlagIdSuffixShort = FlagName{"s"} FlagLimit = FlagName{"limit"} FlagLimitShort = FlagName{"l"} FlagFrom = FlagName{"from"} FlagFromShort = FlagName{"f"} // waiting FlagState = FlagName{"state"} FlagStateShort = FlagName{"s"} FlagTime = FlagName{"time"} FlagTimeShort = FlagName{"t"} // inspecting FlagStates = FlagName{"states"} FlagStatesShort = FlagName{"z"} FlagStatesAll = FlagName{"states-all"} FlagStatesAllShort = FlagName{"Z"} FlagDisconn = FlagName{"disconn"} FlagDisconnShort = FlagName{"d"} FlagAll = FlagName{"all"} FlagSum = FlagName{"sum"} )
var ( GroupMutating = GroupId{"mutating"} GroupWaiting = GroupId{"waiting"} GroupInspecting = GroupId{"inspecting"} GroupRepl = GroupId{"repl"} )
var ErrSyntax = errors.New("syntax error")
Functions ¶
func AddErrSyntax ¶
AddErrSyntax wraps an error in the ErrSyntax sentinel and adds to a machine. TODO align with manual.md version, return am.Result
func InspectingCmds ¶
func ListingFlags ¶
func MutationCmds ¶
func WaitingCmds ¶
Types ¶
type A ¶
type A struct {
Args `json:"-"`
Id string `log:"id"`
Addrs []NamedAddr `log:"addr"`
Lines []string
States []string `log:"states"`
// machine ID
MachId string `log:"mach"`
// list of machine IDs
MachIds []string
// Mutation arguments passed from a Cobra cmd handler.
MutArgs [2][]string
// Arguments passed to the CLI from the shell
CliArgs []string
// RpcCh is a return channel for a list of [rpc.NetworkMachine]. It has to be
// buffered or the mutation will fail.
RpcCh chan<- []*rpc.Client
ListFilters *ListFilters
}
A is a struct for node arguments. It's a typesafe alternative to am.A.
type Args ¶ added in v0.19.0
Args is shared pkg args for Any state
func (Args) ArgsPrefix ¶ added in v0.19.0
type FlagName ¶ added in v0.19.7
FlagName is a REPL flag name, long or short. Repeated shorthand values are intentional, eg -a is used by --req-all and --active.
type History ¶
type History struct {
// contains filtered or unexported fields
}
type ListFilters ¶
type ListFilters struct {
amhelp.MachGroupFilter
// Include never connected machines
NoSchema bool
// Exclude disconnected machines
SkipDisconn bool
}
ListFilters are REPL-specific machine filters, based on amhelp.MachGroupFilter.
type NamedAddr ¶ added in v0.19.7
NamedAddr is a named machine address. Names are stable across address file refreshes, and Addr may end with /* for WebSockets. Manual addresses are added from the REPL and survive watched address file updates.
type Repl ¶
type Repl struct {
// TODO JSON output
*am.ExceptionHandler
Mach *am.Machine
// Addrs are named addresses, ending with /* for WebSockets. Names are
// stable across watched address file changes, keeping existing connections.
Addrs []NamedAddr
Cmd *cobra.Command
C *console.Console
// am-dbg address for new clients
DbgAddr string
// contains filtered or unexported fields
}
func (*Repl) AddrChangedState ¶ added in v0.12.0
func (*Repl) CmdAddState ¶
func (*Repl) CmdGroupAddState ¶
func (*Repl) CmdGroupRemoveState ¶
func (*Repl) CmdGroupSetState ¶ added in v0.19.7
func (*Repl) CmdRemoveState ¶
func (*Repl) CmdSetState ¶ added in v0.19.7
func (*Repl) ConnectedState ¶
func (*Repl) ConnectingState ¶
func (*Repl) DisconnectedState ¶
func (*Repl) DisconnectingState ¶
func (*Repl) ErrNetworkState ¶ added in v0.12.0
func (*Repl) ListMachines ¶
func (r *Repl) ListMachines(filters *ListFilters) ([]*arpc.Client, error)
func (*Repl) ListMachinesState ¶
func (*Repl) NetMach ¶ added in v0.17.1
func (r *Repl) NetMach(machId string) *arpc.NetworkMachine
NetMach returns an RPC worker with a given ID, or nil.
func (*Repl) NetMachArgs ¶ added in v0.17.1
NetMachArgs returns a list of registered typed args for a given machine.