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.
-
urfave/cli
A simple, fast, and fun package for building command line apps in Go -
elvish
Elvish = Expressive Programming Language + Versatile Interactive Shell -
survey
A golang library for building interactive and accessible prompts with full support for windows and posix terminals. -
kingpin
CONTRIBUTIONS ONLY: A Go (golang) command line and flag parser -
The Platinum Searcher
A code search tool similar to ack and the_silver_searcher(ag). It supports multi platforms and multi encodings. -
pflag
Drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags. -
readline
Readline is a pure go(golang) implementation for GNU-Readline kind library -
mitchellh/cli
A Go library for implementing command-line interfaces. -
complete
bash completion written in go + bash completion for go command -
flaggy
Idiomatic Go input parsing with subcommands, positional values, and flags at any position. No required project or package layout and no external dependencies. -
wmenu
An easy to use menu structure for cli applications that prompts users to make choices. -
commandeer
Automatically sets up command line flags based on struct fields and tags. -
flag
Flag is a simple but powerful command line option parsing library for Go support infinite level subcommand -
cmdr
POSIX-compliant command-line UI (CLI) parser and Hierarchical-configuration operations -
wlog
A simple logging interface that supports cross-platform color and concurrency. -
go-getoptions
Fully featured Go (golang) command line option parser with built-in auto-completion support. -
argv
A Go library to split command line string as arguments array using the bash syntax. -
command-chain
A go library for easy configure and run command chains. Such like pipelining in unix shells.
Access the most powerful time series database as a service
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)