Provide a better help for the shell

This commit is contained in:
Jan Philipp Timme 2019-01-01 21:16:06 +01:00
parent f1a6259256
commit 187164fc7d
1 changed files with 8 additions and 4 deletions

View File

@ -64,7 +64,7 @@ func displayMessageDetails(fields []string, writer io.Writer, state shellState)
func interactiveShell(reader io.Reader, writer io.Writer) {
var state shellState = initialShellState()
fmt.Fprintln(writer, "Let's try an interactive shell!")
printHelp(writer)
scanner := bufio.NewScanner(reader)
for {
fmt.Fprint(writer, "> ")
@ -104,11 +104,15 @@ func interactiveShell(reader io.Reader, writer io.Writer) {
break
}
}
fmt.Fprintln(writer, "\nGoodbye!\n")
}
func printHelp(writer io.Writer) {
fmt.Fprintln(writer, "Available commands:")
fmt.Fprintln(writer, "?, help: display this output")
fmt.Fprintln(writer, "exit: quit this program")
fmt.Fprintln(writer, "help\tdisplay this output")
fmt.Fprintln(writer, "exit\tquit this program")
fmt.Fprintln(writer, "reload\treload mailq")
fmt.Fprintln(writer, "sort\tdefine how to sort mailq before showing")
fmt.Fprintln(writer, "show\tshow mailq")
fmt.Fprintln(writer, "summary\tshow mailq summary")
fmt.Fprintln(writer, "")
}