aboutsummaryrefslogtreecommitdiffstats
path: root/commands/patch/term.go
blob: c81f6995b2ddc0277e64ca03c6d66e2ea43585bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package patch

import (
	"git.sr.ht/~rjarry/aerc/commands"
	"git.sr.ht/~rjarry/aerc/lib/pama"
)

type Term struct {
	Cmd []string `opt:"..." required:"false"`
}

func init() {
	register(Term{})
}

func (Term) Description() string {
	return "Open a shell or run a command in the current project's directory."
}

func (Term) Context() commands.CommandContext {
	return commands.GLOBAL
}

func (Term) Aliases() []string {
	return []string{"term"}
}

func (t Term) Execute(_ []string) error {
	p, err := pama.New().CurrentProject()
	if err != nil {
		return err
	}
	return commands.TermCoreDirectory(t.Cmd, p.Root)
}