fixed
Go to file
c-bata 7a1c82652e Add some color option 2017-07-17 04:55:05 +09:00
_tools Add tools 2017-07-17 03:53:23 +09:00
prompt Add some color option 2017-07-17 04:55:05 +09:00
.gitignore Initial commit 2017-07-03 23:36:56 +09:00
LICENSE Update LICENSE 2017-07-16 13:51:31 +09:00
Makefile Add makefile 2017-07-04 00:52:39 +09:00
README.md Update README.md 2017-07-17 03:41:00 +09:00
glide.lock Add glide 2017-07-03 23:43:52 +09:00
glide.yaml Add glide 2017-07-03 23:43:52 +09:00
main.go Add some color option 2017-07-17 04:55:05 +09:00

go-prompt-toolkit

Library for building powerful interactive command lines in Golang.

demo

Usage

package main

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

func executor(s string) string {
    r := "Your input: " + s
    return r
}

func completer(s string) []string {
    // Return the completion items by checking user input.
    return []string{
        "users",
        "articles",
        "comments",
        "groups",
        "tags",
    }
}

func main() {
    pt := prompt.NewPrompt(
        executor,
        completer,
        prompt.MaxCompletionsOption(8),
        prompt.PrefixOption(">>> "),
        prompt.PrefixColorOption("blue"),
        prompt.TitleOption("SQLITE CLI"),
    )
    defer fmt.Println("\nGoodbye!")
    pt.Run()
}

Options

options

ParserOption(x ConsoleParser)

WriterOption(x ConsoleWriter)

TitleOption(x string)

PrefixOption(x string)

PrefixColorOption(x string)

CompletionTextColor(x string)

CompletionBackgroundColor(x string)

SelectedCompletionTextColor(x string)

SelectedCompletionBackgroundColor(x string)

MaxCompletionsOption(x uint16)

Similar Projects

Projects using go-prompt-toolkit

  • kube-prompt : This is available soon...

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.