File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,19 +179,9 @@ func providerCommandSuggestions() []prompt.Suggest {
179179 {Text : "clear" , Description : "clear the console" },
180180 {Text : "exit" , Description : "exit the console" },
181181 }
182- if canReturnToPreviousConsole () {
183- suggestions = append (suggestions , prompt.Suggest {
184- Text : "back" ,
185- Description : "return to the previous console" ,
186- })
187- }
188182 return suggestions
189183}
190184
191- func canReturnToPreviousConsole () bool {
192- return len (consoleStack ) > 0
193- }
194-
195185func showTopicSuggestions () []prompt.Suggest {
196186 return showTopicSuggestionsData
197187}
Original file line number Diff line number Diff line change 66 "os"
77 "os/signal"
88 "sort"
9+ "strings"
910 "time"
1011
1112 "github.com/404tk/cloudtoolkit/runner/payloads"
@@ -17,9 +18,11 @@ import (
1718)
1819
1920func Executor (s string ) {
21+ s = strings .TrimSpace (s )
2022 if s == "" {
2123 return
2224 }
25+ rememberConsoleCommand (s )
2326 cmd , args := utils .ParseCmd (s )
2427
2528 // Only payload `run` needs a cancellable context with timeout + SIGINT wiring.
Original file line number Diff line number Diff line change 1+ package console
2+
3+ import (
4+ "strings"
5+
6+ "github.com/404tk/go-prompt"
7+ )
8+
9+ var sharedConsoleHistory []string
10+
11+ func rememberConsoleCommand (cmd string ) {
12+ cmd = strings .TrimSpace (cmd )
13+ if cmd == "" {
14+ return
15+ }
16+ sharedConsoleHistory = append (sharedConsoleHistory , cmd )
17+ }
18+
19+ func sharedConsoleHistorySnapshot () []string {
20+ return append ([]string (nil ), sharedConsoleHistory ... )
21+ }
22+
23+ func sharedConsoleHistoryOption () prompt.Option {
24+ return prompt .OptionHistory (sharedConsoleHistorySnapshot ())
25+ }
Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ func internation(uuid string) {
126126 actionCompleter ,
127127 prompt .OptionPrefix (fmt .Sprintf ("ctk > %s > " , provider )),
128128 prompt .OptionInputTextColor (prompt .White ),
129+ sharedConsoleHistoryOption (),
129130 )
130131 currentConsole = p
131132 p .Run ()
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ func loadModule(m string) error {
4242 actionCompleter ,
4343 prompt .OptionPrefix (fmt .Sprintf ("ctk > %s > " , m )),
4444 prompt .OptionInputTextColor (prompt .White ),
45+ sharedConsoleHistoryOption (),
4546 )
4647 currentConsole = p
4748 p .Run ()
You can’t perform that action at this time.
0 commit comments