cli

package
v0.0.0-...-80a4a0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StyleThinUnicode = &simpletable.Style{
	Border: &simpletable.BorderStyle{
		TopLeft:            "┌",
		Top:                "─",
		TopRight:           "┐",
		Right:              "│",
		BottomRight:        "┘",
		Bottom:             "─",
		BottomLeft:         "└",
		Left:               "│",
		TopIntersection:    "┬",
		BottomIntersection: "┴",
	},
	Divider: &simpletable.DividerStyle{
		Left:         "├",
		Center:       "─",
		Right:        "┤",
		Intersection: "┼",
	},
	Cell: "│",
}

Functions

func RunCommand

func RunCommand(registry Registry)

func UnpackArguments

func UnpackArguments(args []string) map[string]string

Types

type Command

type Command struct {
	Command      string
	Title        string
	Description  string
	Args         []CommandArgument
	ExampleUsage map[string]string
	Handler      func(c CommandArgumentValue)
}

func (Command) FindMissingArgs

func (c Command) FindMissingArgs(args []string) []CommandArgument

func (Command) HasCorrectAmountOfArgs

func (c Command) HasCorrectAmountOfArgs(args []string) bool

type CommandArgument

type CommandArgument struct {
	Name        string
	Description string
	Required    bool
	Flag        bool
}

type CommandArgumentValue

type CommandArgumentValue struct {
	Store map[string]string
}

func (CommandArgumentValue) ArgumentExist

func (c CommandArgumentValue) ArgumentExist(key string) bool

func (CommandArgumentValue) ArgumentOnly

func (c CommandArgumentValue) ArgumentOnly(key string) bool

func (CommandArgumentValue) GetArgument

func (c CommandArgumentValue) GetArgument(key string, defaultValue string) string

func (CommandArgumentValue) NoArguments

func (c CommandArgumentValue) NoArguments() bool

type Registry

type Registry struct {
	Commands map[string]Command
}

func MakeRegistry

func MakeRegistry() Registry

func (*Registry) AddCommand

func (container *Registry) AddCommand(callable Command)

func (*Registry) GetCommand

func (container *Registry) GetCommand(callable string) (Command, error)

func (*Registry) GetCommands

func (container *Registry) GetCommands() map[string]Command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL