Example #1
0
func main() {
	fmt.Println("Starting up...")

	flag.Parse()
	types, functions := gonav.ProcessDir(*root, *includeBody)

	for {
		res, _ := readline.ReadLine(&prompt)
		if res == nil {
			break
		}
		line := strings.TrimSpace(*res)

		switch line {
		case "quit", "q", "exit":
			return
		}

		if line != "" {
			readline.AddHistory(line)
		}

		found := false

		byType, ok := types[line]
		if ok {
			found = true
			fmt.Println("Types:")
			fmt.Println("======")
			for _, f := range byType {
				fmt.Println(*f)
				fmt.Println("===========")
			}
		}

		byFunction, ok := functions[line]
		if ok {
			found = true
			fmt.Println("Functions:")
			fmt.Println("==========")
			for _, f := range byFunction {
				fmt.Println(*f)
				fmt.Println("===========")
			}
		}

		if !found {
			fmt.Println("Found nothing")
		}
	}
	fmt.Println()
}
Example #2
0
func main() {
	prompt := "by your command> "

	//loop until ReadLine returns nil (signalling EOF)
L:
	for {
		switch result := readline.ReadLine(&prompt); true {
		case result == nil:
			break L //exit loop

		case *result != "": //ignore blank lines
			println(*result)
			readline.AddHistory(*result) //allow user to recall this line
		}
	}
}
Example #3
0
// Interactive shell: prompt for commands on stdin and run them
func (deck *ControlDeck) Shell() {
    prompt := "-"
    for {
        line := readline.ReadLine(&prompt)

        if line == nil {
            break
        }

        if *line == "" {
            continue
        }

        deck.RunCommand(*line)
        readline.AddHistory(*line)
    }
}
Example #4
0
/* Read from stdin and pass it along to outch channel */
func prompter(outch chan string) {
	var linestr *string
	var eofStr = `exit`

	for {
		promptFunc := getPromptFunc(Status())
		outputStr := promptFunc()

		switch linestr = readline.ReadLine(&outputStr); true {

		case linestr == nil:
			linestr = &eofStr

		case *linestr != "":
			readline.AddHistory(*linestr)
		}

		outch <- *linestr
		_ = <-outch //wait till we can prompt again
	}
}