summary refs log tree commit diff stats
path: root/.gitignore
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-01-14 08:07:24 -0500
committerDrew DeVault <sir@cmpwn.com>2019-01-14 08:07:24 -0500
commitd35213eaabeda8749cd0aab103e5895cfcd96e94 (patch)
tree7722340021b0ffe0482eaabf902421883435b6ed /.gitignore
parent501c95d852971775d64b97872fe63ecea367c525 (diff)
downloadaerc-d35213eaabeda8749cd0aab103e5895cfcd96e94.tar.gz
Add cursor handling in ex line
Diffstat (limited to '.gitignore')
0 files changed, 0 insertions, 0 deletions
aerc/blame/commands/set.go?h=0.6.0&id=c6b776adbfb11ba34756a1d4f770b15c2fb3cb46'>^
d85f671 ^

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
66
67
68
69




















                                                
                               



                              
                                                                 






































                                                                
                                                             

                                  
package commands

import (
	"errors"
	"strings"

	"git.sr.ht/~sircmpwn/aerc/widgets"

	"github.com/go-ini/ini"
)

type Set struct{}

func setUsage() string {
	return "set <category>.<option> <value>"
}

func init() {
	register(Set{})
}

func (Set) Aliases() []string {
	return []string{"set"}

}

func (Set) Complete(aerc *widgets.Aerc, args []string) []string {
	return nil
}

func SetCore(aerc *widgets.Aerc, args []string) error {
	if len(args) != 3 {
		return errors.New("Usage: " + setUsage())
	}

	config := aerc.Config()

	parameters := strings.Split(args[1], ".")

	if len(parameters) != 2 {
		return errors.New("Usage: " + setUsage())
	}

	category := parameters[0]
	option := parameters[1]
	value := args[2]

	new_file := ini.Empty()

	section, err := new_file.NewSection(category)

	if err != nil {
		return nil
	}

	if _, err := section.NewKey(option, value); err != nil {
		return err
	}

	if err := config.LoadConfig(new_file); err != nil {
		return err
	}

	return nil
}

func (Set) Execute(aerc *widgets.Aerc, args []string) error {
	return SetCore(aerc, args)
}