Description
GoConsole component allows you to create command-line commands. Your console commands can be used for any recurring task, such as cronjobs, imports, or other batch jobs. Command arguments and options follow the docopt standard. This library provide several helper for styling of the command’s output.
Go-Console alternatives and similar packages
Based on the "Standard CLI" category.
Alternatively, view Go-Console alternatives based on common mentions on social networks and blogs.
-
survey
DISCONTINUED. A golang library for building interactive and accessible prompts with full support for windows and posix terminals. -
The Platinum Searcher
A code search tool similar to ack and the_silver_searcher(ag). It supports multi platforms and multi encodings. -
flaggy
Idiomatic Go input parsing with subcommands, positional values, and flags at any position. No required project or package layout and no external dependencies. -
flag
Flag is a simple but powerful command line option parsing library for Go support infinite level subcommand -
go-getoptions
Fully featured Go (golang) command line option parser with built-in auto-completion support. -
command-chain
A go library for easy configure and run command chains. Such like pipelining in unix shells.
InfluxDB - Purpose built for real-time analytics at any scale.
Do you think we are missing an alternative of Go-Console or a related project?
README
The Go console component
The Console component eases the creation of beautiful and testable command line interfaces.
GoConsole component allows you to create command-line commands. Your console commands can be used for any recurring task, such as cronjobs, imports, or other batch jobs. Command arguments and options follow the docopt standard. This library provide several helper for styling of the command's output.
GoConsole is a lightweight equivalent in Go to the Console Component of Symfony PHP framework.
Creating a Console Application
package main
import (
"fmt"
"github.com/DrSmithFr/go-console/pkg/input/argument"
"github.com/DrSmithFr/go-console/pkg/input/option"
"github.com/DrSmithFr/go-console/pkg/style"
)
func main() {
io := style.
NewConsoleStyler().
AddInputArgument(
argument.
New("name", argument.REQUIRED),
).
AddInputOption(
option.
New("foo", option.NONE).
SetShortcut("f"),
).
ParseInput().
ValidateInput()
// enable stylish errors
defer io.HandleRuntimeException()
//
// Do what you want with console and args !
//
io.Title("Starting console")
io.TextArray([]string{
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
})
io.Note(
fmt.Sprintf(
"name argument value '%s'",
io.GetInput().GetArgument("name"),
),
)
if option.DEFINED == io.GetInput().GetOption("foo") {
io.Success("foo option is set")
}
panic("this error will be stylish!")
}
Learn more
- [How to use input options and arguments](docs/console-input.md)
- [How to style the console output](docs/console-output.md)