Commit 9680fd8 mritd
committed
1 parent 84829e4 commit 9680fd8 Copy full SHA for 9680fd8
File tree 3 files changed +27
-2
lines changed
3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ var ctxCmd = &cobra.Command{
12
12
Long : `
13
13
Change current context.` ,
14
14
Run : func (cmd * cobra.Command , args []string ) {
15
- _ = cmd .Help ()
15
+ if len (args ) == 0 {
16
+ mmh .InteractiveSetContext ()
17
+ } else {
18
+ _ = cmd .Help ()
19
+ }
16
20
},
17
21
}
18
22
Original file line number Diff line number Diff line change @@ -36,3 +36,24 @@ func InteractiveLogin() {
36
36
idx := s .Run ()
37
37
SingleLogin (CurrentContext .Servers [idx ].Name )
38
38
}
39
+
40
+ func InteractiveSetContext () {
41
+ cfg := & promptx.SelectConfig {
42
+ ActiveTpl : `» {{ .Name | cyan }}` ,
43
+ InactiveTpl : ` {{ .Name | white }}` ,
44
+ SelectPrompt : "Context" ,
45
+ SelectedTpl : `{{ "» " | green }}{{ .Name | green }}` ,
46
+ DisPlaySize : 9 ,
47
+ DetailsTpl : `
48
+ --------- Context ----------
49
+ {{ "Name:" | faint }} {{ .Name | faint }}
50
+ {{ "ConfigPath:" | faint }} {{ .ConfigPath | faint }}` ,
51
+ }
52
+
53
+ s := & promptx.Select {
54
+ Items : Main .Contexts ,
55
+ Config : cfg ,
56
+ }
57
+ idx := s .Run ()
58
+ UseContext (Main .Contexts [idx ].Name )
59
+ }
Original file line number Diff line number Diff line change 1
- v1.3.4
1
+ v1.3.5
You can’t perform that action at this time.
0 commit comments