summary refs log tree commit diff stats
path: root/doc/pydoc/ranger.ext.html
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-03-17 11:43:14 +0100
committerhut <hut@lavabit.com>2010-03-17 11:43:14 +0100
commit186407335a1b5966b0dd0ba3deba88bd17463c18 (patch)
tree55910daa17545bb55ee09551eba02f51927fb395 /doc/pydoc/ranger.ext.html
parent9dfdb4286d33b0668e2f195605427bade75c78ea (diff)
downloadranger-186407335a1b5966b0dd0ba3deba88bd17463c18.tar.gz
help.fileop: updated doc
removed the part "WITHOUT CONFIRMATION" since I actually built in
a confirmation dialog.
Diffstat (limited to 'doc/pydoc/ranger.ext.html')
0 files changed, 0 insertions, 0 deletions
n.com> 2019-12-21 09:27:53 -0500 modify-labels: adapt to ProvidesMessages' href='/akspecs/aerc/commit/commands/msg/modify-labels.go?h=0.5.0&id=a744df724f8b7acb0ac231a615192d33c414012e'>a744df7 ^
a93b4de ^
a744df7 ^
a93b4de ^


a744df7 ^
a93b4de ^











a744df7 ^
a93b4de ^





7c89143 ^
a93b4de ^



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
63
64
65





                
                                           

                                               












                                                                          
                                             







                                                                         



                               
         
                             


                          
 











                                                            
                                                   





                                                                         
                                                             



                  
package msg

import (
	"errors"
	"time"

	"git.sr.ht/~sircmpwn/aerc/commands"
	"git.sr.ht/~sircmpwn/aerc/widgets"
	"git.sr.ht/~sircmpwn/aerc/worker/types"
)

type ModifyLabels struct{}

func init() {
	register(ModifyLabels{})
}

func (ModifyLabels) Aliases() []string {
	return []string{"modify-labels"}
}

func (ModifyLabels) Complete(aerc *widgets.Aerc, args []string) []string {
	return commands.GetLabels(aerc, args)
}

func (ModifyLabels) Execute(aerc *widgets.Aerc, args []string) error {
	changes := args[1:]
	if len(changes) == 0 {
		return errors.New("Usage: modify-labels <[+-]label> ...")
	}

	h := newHelper(aerc)
	store, err := h.store()
	if err != nil {
		return err
	}
	uids, err := h.uids()
	if err != nil {
		return err
	}

	var add, remove []string
	for _, l := range changes {
		switch l[0] {
		case '+':
			add = append(add, l[1:])
		case '-':
			remove = append(remove, l[1:])
		default:
			// if no operand is given assume add
			add = append(add, l)
		}
	}
	store.ModifyLabels(uids, add, remove, func(
		msg types.WorkerMessage) {

		switch msg := msg.(type) {
		case *types.Done:
			aerc.PushStatus("labels updated", 10*time.Second)
		case *types.Error:
			aerc.PushError(" "+msg.Error.Error())
		}
	})
	return nil
}