about summary refs log tree commit diff stats
path: root/js/games/nluqo.github.io/~bh/ssch19
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2025-01-11 12:21:17 -0500
committerelioat <elioat@tilde.institute>2025-01-11 12:21:17 -0500
commit95067512ffb2ee129581146cc433ddd9c79c3b49 (patch)
tree7063c1c9b093a6a73f87b9faea95108dac274ff5 /js/games/nluqo.github.io/~bh/ssch19
parent9eb44ff7206bf993679208dc4fbacbff57356998 (diff)
downloadtour-95067512ffb2ee129581146cc433ddd9c79c3b49.tar.gz
*
Diffstat (limited to 'js/games/nluqo.github.io/~bh/ssch19')
0 files changed, 0 insertions, 0 deletions
4:03 -0300 committer Drew DeVault <sir@cmpwn.com> 2019-09-04 16:30:57 -1000 all: purge redundant underscores' href='/akspecs/aerc/commit/commands/compose/detach.go?h=0.5.0&id=6838c23478944a9b45df1fa9a0f432ec77423987'>6838c23 ^
0ee7d30 ^


6838c23 ^
0ee7d30 ^
0ee7d30 ^


6838c23 ^
0ee7d30 ^


39307a6 ^

0ee7d30 ^













caad1b2 ^

0ee7d30 ^


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



               
                 
              

                                          
                                  







                          
                                  


                                 
                                                                    
                                                             


                                        
                                                                


                                                             

                                                  













                                                                              

                                                                          


                  
package compose

import (
	"fmt"
	"strings"
	"time"

	"git.sr.ht/~sircmpwn/aerc/widgets"
	"github.com/gdamore/tcell"
)

type Detach struct{}

func init() {
	register(Detach{})
}

func (Detach) Aliases() []string {
	return []string{"detach"}
}

func (Detach) Complete(aerc *widgets.Aerc, args []string) []string {
	composer, _ := aerc.SelectedTab().(*widgets.Composer)
	return composer.GetAttachments()
}

func (Detach) Execute(aerc *widgets.Aerc, args []string) error {
	var path string
	composer, _ := aerc.SelectedTab().(*widgets.Composer)

	if len(args) > 1 {
		path = strings.Join(args[1:], " ")
	} else {
		// if no attachment is specified, delete the first in the list
		atts := composer.GetAttachments()
		if len(atts) > 0 {
			path = atts[0]
		} else {
			return fmt.Errorf("No attachments to delete")
		}
	}

	if err := composer.DeleteAttachment(path); err != nil {
		return err
	}

	aerc.PushStatus(fmt.Sprintf("Detached %s", path), 10*time.Second).
		Color(tcell.ColorDefault, tcell.ColorGreen)

	return nil
}