-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathconfig.go
More file actions
49 lines (42 loc) · 1.09 KB
/
Copy pathconfig.go
File metadata and controls
49 lines (42 loc) · 1.09 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
45
46
47
48
49
package cli
import (
"fmt"
"os"
"github.com/jandedobbeleer/oh-my-posh/src/cache"
"github.com/jandedobbeleer/oh-my-posh/src/cli/dsc"
"github.com/jandedobbeleer/oh-my-posh/src/cmdtree"
"github.com/jandedobbeleer/oh-my-posh/src/config"
basedsc "github.com/jandedobbeleer/oh-my-posh/src/dsc"
)
var configCmd = &cmdtree.Command{
Use: "config edit",
Short: "Interact with the config",
Long: `Interact with the config.
You can export or edit the config (via the editor specified in the environment variable "EDITOR").`,
ValidArgs: []string{
"edit",
},
Args: NoArgsOrOneValidArg,
Run: func(cmd *cmdtree.Command, args []string) {
if len(args) == 0 {
_ = cmd.Help()
return
}
switch args[0] {
case "edit":
cache.Init(os.Getenv("POSH_SHELL"))
if configPath, OK := cache.Session.Get[string](config.SourceKey); OK {
exitcode = editFileWithEditor(configPath)
return
}
fmt.Println("no config found in session cache")
exitcode = 666
default:
_ = cmd.Help()
}
},
}
func init() {
configCmd.AddCommand(basedsc.Command(dsc.ConfigDSC()))
RootCmd.AddCommand(configCmd)
}