Popularity
1.3
Growing
Activity
0.0
Stable
5
2
3

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.

Programming language: Go
License: The Unlicense
Latest version: v1.0.0

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.

Do you think we are missing an alternative of Go-Console or a related project?

Add another 'Standard CLI' Package

README

The Go console component

CircleCI GolangCI Go Report Card

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)