aboutsummaryrefslogtreecommitdiff
path: root/commands/term.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/term.go')
-rw-r--r--commands/term.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/commands/term.go b/commands/term.go
index 22957635..1a0bcc69 100644
--- a/commands/term.go
+++ b/commands/term.go
@@ -9,7 +9,9 @@ import (
"git.sr.ht/~rjarry/aerc/widgets"
)
-type Term struct{}
+type Term struct {
+ Cmd []string `opt:"..." required:"false"`
+}
func init() {
register(Term{})
@@ -23,23 +25,22 @@ func (Term) Complete(aerc *widgets.Aerc, args []string) []string {
return nil
}
-// The help command is an alias for `term man` thus Term requires a simple func
-func TermCore(aerc *widgets.Aerc, args []string) error {
- if len(args) == 1 {
+func (t Term) Execute(aerc *widgets.Aerc, args []string) error {
+ if len(t.Cmd) == 0 {
shell, err := loginshell.Shell()
if err != nil {
return err
}
- args = append(args, shell)
+ t.Cmd = []string{shell}
}
- term, err := widgets.NewTerminal(exec.Command(args[1], args[2:]...))
+ term, err := widgets.NewTerminal(exec.Command(t.Cmd[0], t.Cmd[1:]...))
if err != nil {
return err
}
- tab := aerc.NewTab(term, args[1])
+ tab := aerc.NewTab(term, t.Cmd[0])
term.OnTitle = func(title string) {
if title == "" {
- title = args[1]
+ title = t.Cmd[0]
}
if tab.Name != title {
tab.Name = title
@@ -54,7 +55,3 @@ func TermCore(aerc *widgets.Aerc, args []string) error {
}
return nil
}
-
-func (Term) Execute(aerc *widgets.Aerc, args []string) error {
- return TermCore(aerc, args)
-}