command

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

TODO:

> Split up in separate files
	> command.go
	> application.go
	> descriptor.go
> Document symbols
> Write unit tests

Final notes:

This package DOES NOT hold a stable public API and is meant for internal purposes only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCommandArgs

func ExtractCommandArgs(input []string) (cmd string, args []string)

Types

type Application

type Application struct {
	IO
	Runner
	// contains filtered or unexported fields
}

func NewApplication

func NewApplication(ctx context.Context, input *os.File, output *os.File, error *os.File) *Application

func (*Application) Description

func (d *Application) Description() string

func (*Application) Name

func (d *Application) Name() string

func (Application) ReadLn

func (app Application) ReadLn() string

func (Application) Register

func (app Application) Register(cmd Command)

func (Application) Run

func (app Application) Run(command string, args []string) int

func (*Application) SetDescription

func (d *Application) SetDescription(description string)

func (*Application) SetName

func (d *Application) SetName(name string)

func (Application) Usage

func (app Application) Usage()

func (Application) Write

func (app Application) Write(message string)

func (Application) WriteError

func (app Application) WriteError(message string)

func (Application) WriteErrorLn

func (app Application) WriteErrorLn(message string)

func (Application) WriteLn

func (app Application) WriteLn(message string)

type BaseCommand

type BaseCommand struct {
	Command
	// contains filtered or unexported fields
}

func (BaseCommand) Description

func (cmd BaseCommand) Description() string

func (BaseCommand) Init

func (cmd BaseCommand) Init(args []string) ([]string, error)

func (BaseCommand) Name

func (cmd BaseCommand) Name() string

type Command

type Command interface {
	Describable
	Init(args []string) ([]string, error)
	Run(args []string, io IO) int
}

func NewGetCommand

func NewGetCommand(engine search.Engine, exportFactory export.Factory) Command

func NewSearchCommand

func NewSearchCommand(engine search.Engine) Command

type Commands

type Commands map[string]*Command

type Describable

type Describable interface {
	Name() string
	Description() string
}

type Describers

type Describers []Describable

func (Describers) Len

func (d Describers) Len() int

func (Describers) Less

func (d Describers) Less(i, j int) bool

func (Describers) Swap

func (d Describers) Swap(i, j int)

type IO

type IO interface {
	ReadLn() string
	Write(message string)
	WriteLn(message string)
	WriteError(message string)
	WriteErrorLn(message string)
}

type Runner

type Runner interface {
	Run(command string, args []string) int
	Register(cmd Command)
	Usage()
}

Jump to

Keyboard shortcuts

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