fixed
Go to file
2017-08-07 20:07:02 +09:00
_example Set nonblocking mode 2017-08-07 20:07:02 +09:00
_tools Fix vt100_debug.go 2017-08-04 16:41:32 +09:00
.gitignore Initial commit 2017-07-03 23:36:56 +09:00
bisect.go Move go files to project root 2017-07-18 05:27:57 +09:00
buffer_test.go Move go files to project root 2017-07-18 05:27:57 +09:00
buffer.go Replace panic to log.Print 2017-08-06 15:21:14 +09:00
completion.go Rename Completion to Suggest 2017-08-04 20:30:50 +09:00
console_interface.go Add refactor change 2017-08-04 16:23:18 +09:00
document_test.go Move go files to project root 2017-07-18 05:27:57 +09:00
document.go Move go files to project root 2017-07-18 05:27:57 +09:00
filter_test.go Rename Completion to Suggest 2017-08-04 20:30:50 +09:00
filter.go Rename Completion to Suggest 2017-08-04 20:30:50 +09:00
history.go Fix history clear 2017-08-04 20:33:28 +09:00
key_string.go Move go files to project root 2017-07-18 05:27:57 +09:00
key.go Add refactor change 2017-08-04 16:23:18 +09:00
LICENSE Update LICENSE 2017-07-16 13:51:31 +09:00
Makefile Update Makefile 2017-07-18 05:32:25 +09:00
option.go Remove output options 2017-08-06 15:31:44 +09:00
prompt.go Set nonblocking mode 2017-08-07 20:07:02 +09:00
README.md Set nonblocking mode 2017-08-07 20:07:02 +09:00
render_test.go Rename Completion to Suggest 2017-08-04 20:30:50 +09:00
render.go Remove output options 2017-08-06 15:31:44 +09:00
vt100_input.go Add refactor change 2017-08-04 16:23:18 +09:00
vt100_output.go Set bold option 2017-07-19 01:16:57 +09:00

go-prompt-toolkit

demo

Library for building powerful interactive command lines in Golang.

Similar Projects

Projects using go-prompt-toolkit

Getting Started

package main

import (
    "fmt"
    "time"

    "github.com/c-bata/go-prompt-toolkit/prompt"
)

// executor executes command and print the output.
// 1. Execute sql
// 2. Get response and print it
func executor(in string)  {
    out := "something response from db."
    fmt.Println(out)
    return
}

// completer returns the completion items from user input.
func completer(in string) []prompt.Suggest {
    return []primpt.Suggest{
        {Text: "users", Description: "user collections."},
        {Text: "articles", Description: "article is posted by users."},
        {Text: "comments", Description: "comment is inserted with each articles."},
        {Text: "groups", Description: "group is the collection of users."},
        {Text: "tags", Description: "tag contains hash tag like #prompt"},
    }
}

func main() {
    pt := prompt.NewPrompt(
        executor,
        completer,
        prompt.OptionTitle("sqlite3-prompt"),
        prompt.OptionPrefix(">>> "),
        prompt.OptionPrefixColor(prompt.Blue),
    )
    defer fmt.Println("\nGoodbye!")
    pt.Run()
}

Options

options

OptionParser(x ConsoleParser)

OptionWriter(x ConsoleWriter)

OptionTitle(x string)

OptionPrefix(x string)

OptionPrefixTextColor(x Color)

OptionPrefixBackgroundColor(x Color)

OptionInputTextColor(x Color)

OptionInputBGColor(x Color)

OptionPreviewSuggestionTextColor(x Color)

OptionPreviewSuggestionBGColor(x Color)

OptionSuggestionTextColor(x Color)

OptionSuggestionBGColor(x Color)

OptionSelectedSuggestionTextColor(x Color)

OptionSelectedSuggestionBGColor(x Color)

OptionMaxCompletions(x uint16)

OptionDescriptionTextColor(x Color)

OptionDescriptionBGColor(x Color)

OptionSelectedDescriptionTextColor(x Color)

OptionSelectedDescriptionBGColor(x Color)

LICENSE

MIT License

Copyright (c) 2017 Masashi SHIBATA

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.