diff --git a/main.go b/main.go index c43be8c..00067d6 100644 --- a/main.go +++ b/main.go @@ -39,10 +39,6 @@ func parseArguments() { settings["usePager"] = strconv.FormatBool(*usePagerPtr) } -func interactiveShell() { - -} - func showQueue() { queue, err := fetchQueue() if err != nil { diff --git a/shell.go b/shell.go new file mode 100644 index 0000000..eb8ee33 --- /dev/null +++ b/shell.go @@ -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") +}