-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmd_edit.go
More file actions
44 lines (38 loc) · 1.04 KB
/
Copy pathcmd_edit.go
File metadata and controls
44 lines (38 loc) · 1.04 KB
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
package main
import "io"
var editHelp = &helpNode{
cmd: "edit",
synopsis: "Edit profiles or scripts with the 'editor'.",
subs: []helpSubNode{
{"profile", func(w io.Writer) {
cmdTitle(w, true, "edit profile")
cmdUsage(w, "Edit the kbdashboard's configuration file.\n")
}},
{"install", func(w io.Writer) {
cmdTitle(w, false, "edit install")
cmdUsage(w, "Edit current profile's installation script.\n")
}},
},
}
func editProfileHandler(args []string, data interface{}) (int, error) {
var argv = []string{gConfig.Editor, gConfig.filepath}
return 0, execCmd(gConfig.Editor, argv)
}
func editInstallHandler(args []string, data interface{}) (int, error) {
p, _, err := getCurrentProfile(gConfig)
if err != nil {
return 0, err
}
script := gConfig.getInstallFilename(p)
ret, err := checkFileExsit(script)
if err != nil {
return 0, err
}
if ret == false {
// create and edit script
if err := createScript(script, p); err != nil {
return 0, err
}
}
return 0, execCmd(gConfig.Editor, []string{gConfig.Editor, script})
}