blob: 5c47d89f0fbe0dcf339e2a993d5f87154815633f (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package patch
import (
"fmt"
"time"
"git.sr.ht/~rjarry/aerc/app"
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/lib/log"
"git.sr.ht/~rjarry/aerc/lib/pama"
)
type Unlink struct {
Tag string `opt:"tag" required:"false" complete:"Complete" desc:"Project tag name."`
}
func init() {
register(Unlink{})
}
func (Unlink) Description() string {
return "Delete all patch tracking data for the specified project."
}
func (Unlink) Context() commands.CommandContext {
return commands.GLOBAL
}
func (Unlink) Aliases() []string {
return []string{"unlink"}
}
func (*Unlink) Complete(arg string) []string {
names, err := pama.New().Names()
if err != nil {
log.Errorf("failed to get completion: %v", err)
return nil
}
return commands.FilterList(names, arg, nil)
}
func (d Unlink) Execute(args []string) error {
m := pama.New()
name := d.Tag
if name == "" {
p, err := m.CurrentProject()
if err != nil {
return err
}
name = p.Name
}
err := m.Unlink(name)
if err != nil {
return err
}
app.PushStatus(fmt.Sprintf("Project '%s' unlinked.", name),
10*time.Second)
return nil
}
|