Documentation ¶
Index ¶
Constants ¶
const ( CmdStrOpen = "open '{{ .Repo.HTMLURL }}'" CmdStrGitClone = "git clone '{{ .Repo.CloneSSHURL }}' '{{ .CloneDir }}'" CmdStrExit = ":Exit '{{ .CloneDir }}'" )
Variables ¶
This section is empty.
Functions ¶
func MatchesActionSyntax ¶
MatchesActionSyntax checks if a string matches the syntax for an app action. this is a colon followed by a command.
Types ¶
type Action ¶
type Action struct { Mode Mode // contains filtered or unexported fields }
func (*Action) ExitMessage ¶
ExitMessage returns the message to display when the action is an exit action.
func (*Action) GoRun ¶
GoRun runs the action within a go-routine and returns an err-channel that will be closed when the action is finished with the resulting error if any.
func (*Action) IsExec ¶
IsExec returns true if the action is an exec action. It will also return the underlying exec.Cmd object.
func (*Action) IsExit ¶
IsExit returns true if the action is an exit action. If true, the ExitMessage will contain the message to display.
func (*Action) OnFinished ¶
type ActionCommand ¶
type ActionCommandBuilder ¶
type ActionCommandBuilder interface {
Build(cmd string, args ...string) ActionCommand
}
type Commander ¶
type Commander struct {
// contains filtered or unexported fields
}
func New ¶
func New(bindings KeyBindings, rfs *repofs.RepoFS, bldr ActionCommandBuilder) *Commander
func (*Commander) Bindings ¶
func (c *Commander) Bindings() KeyBindings
func (*Commander) GetAction ¶
GetAction returns an action for a given key binding. If the key binding is not found, it will attempt to render the command template and return an action with the rendered command.
Special Cases
- ":Exit" - If the command starts with ":Exit", we return an exit action with the message that follows the command.
type KeyBindings ¶
type KeyBindings map[string]KeyCommand
func NewDefaultKeyBindings ¶
func NewDefaultKeyBindings() KeyBindings
func (KeyBindings) Validate ¶
func (k KeyBindings) Validate() error
type KeyCommand ¶
type KeyCommand struct { Cmd string `toml:"cmd"` Desc string `toml:"desc"` Mode Mode `toml:"mode"` }
KeyCommand defines a key binding command that can be executed by the Commander
func (KeyCommand) IsValid ¶
func (k KeyCommand) IsValid() error
func (KeyCommand) String ¶
func (k KeyCommand) String() string
type ShellCommandBuilder ¶
ShellCommandBulder implements the ActionCommandBuilder interface for shell commands. It returns a new ActionCommand that will execute the given command with the given arguments in a shell using the exec package.
func (*ShellCommandBuilder) Build ¶
func (s *ShellCommandBuilder) Build(cmd string, args ...string) ActionCommand
Build implements ActionCommandBuilder.