Skip to content

Pimp your Go app with a dead simple terminal-prompt-like feature.

Notifications You must be signed in to change notification settings

go-prompt/prompt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prompt

Build Status Coverage Status GoDoc

This Go package provides a dead simple 'terminal-prompt-like' for your application.

Install

There is no extra dependencies, just a Go environment is needed. Then:

$ go get gopkg.in/prompt.v1

Use

Here you can see an example about how to add a custom command.

package main

import (
    "fmt"
    "gopkg.in/prompt.v1"
)

func main() {

    prompt.AddCommand(
        "ping",
        "my custom command",
        func(args []string) {
            fmt.Println("pong! Arguments:", args)
        },
    )

    <-prompt.Start()
    // if you don't need to lock, just remove the '<-' operator

    fmt.Println("Bye from main!")
}

This example will show a terminal-prompt-shell-like, where you can try your custom command 'ping'. Or just type 'quit' to close it. For a list of commands type 'help'. You can see this in action here.

TODO

  • a wrapper for exec.Command (from os standard library).