cli

package
v0.0.0-...-60ae506 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 4 Imported by: 5

Documentation

Overview

Package cli provides the command line interface for the application. There are a few commands that are available for use, which are implemented in separate files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCLI

func CreateCLI(commands ...Command) (func(in string), func(in prompt.Document) []prompt.Suggest)

CreateCLI when provided a list of commands, generates a Completer and Executor to run those commands

func StartCLI

func StartCLI(executor func(in string), completer func(in prompt.Document) []prompt.Suggest)

StartCLI runs the command line with the given executor and completer functions

Types

type Command

type Command struct {
	Executor  func([]string) error
	Completer func(prompt.Document) []prompt.Suggest
	// contains filtered or unexported fields
}

Command encapsulates an executable command

func CreateCommand

func CreateCommand(name string, description string, executor func([]string) error, completer func(prompt.Document) []prompt.Suggest) Command

CreateCommand creates a new command with a given name

completer may be nil

type Commands

type Commands []Command

Commands is a list of executable commands

func (Commands) GenerateHelp

func (c Commands) GenerateHelp(explanationText string)

GenerateHelp creates a help command for a given Commands list

func (Commands) GenerateSuggestions

func (c Commands) GenerateSuggestions() []prompt.Suggest

GenerateSuggestions creates a Suggest object for each Command in the Commands list

func (Commands) Match

func (c Commands) Match(name string) (Command, error)

Match attempts to find a command that matches the provided name, returning an error if it does not exist

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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