Introduce a very rough skeleton to implement interactive shell
This commit is contained in:
parent
ad252c7480
commit
b471f6a914
4
main.go
4
main.go
|
@ -39,10 +39,6 @@ func parseArguments() {
|
|||
settings["usePager"] = strconv.FormatBool(*usePagerPtr)
|
||||
}
|
||||
|
||||
func interactiveShell() {
|
||||
|
||||
}
|
||||
|
||||
func showQueue() {
|
||||
queue, err := fetchQueue()
|
||||
if err != nil {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func interactiveShell() {
|
||||
fmt.Println("Let's try an interactive shell!")
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
for {
|
||||
fmt.Print("> ")
|
||||
if !scanner.Scan() {
|
||||
break
|
||||
}
|
||||
text := strings.Trim(scanner.Text(), " ")
|
||||
textFields := strings.Fields(text)
|
||||
if len(textFields) == 0 {
|
||||
continue
|
||||
}
|
||||
cmd := textFields[0]
|
||||
fmt.Printf("Read input: %q\n", textFields)
|
||||
|
||||
switch cmd {
|
||||
|
||||
default:
|
||||
fmt.Printf("Unknown command '%s'\n", cmd)
|
||||
}
|
||||
|
||||
}
|
||||
fmt.Println("\nGoodbye!\n")
|
||||
}
|
Loading…
Reference in New Issue