goarg

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2019 License: MIT Imports: 0 Imported by: 0

README

goarg

GoDoc codecov Go Report Card GitHub last commit GitHub tag License

Golang's simple command line argument parser.

Motivation

We develop this parser to develop chat bots. We implement only minimum functions, so if you want more functions please use other libraries.

https://github.com/avelino/awesome-go#command-line

If you want to convert a string into words, please see go-chatwords .

Example

See examples .

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command func(args ...string) (interface{}, error)

Command represents a command.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler represents a handler.

func NewHandler

func NewHandler(cmd Command, args ...string) Handler

NewHandler returns a handler.

func (*Handler) Match

func (handler *Handler) Match(args ...string) ([]string, bool)

Match returns arguments of command and whether arguments include match of the handler.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser represents a parser.

func NewParser

func NewParser(handlers ...Handler) Parser

NewParser returns a parser.

func (*Parser) Add

func (parser *Parser) Add(cmd Command, args ...string) *Parser

Add adds a handler to the parser.

func (*Parser) Parse

func (parser *Parser) Parse(args ...string) (interface{}, bool, error)

Parse parses arguments and run the command of matched handler.

Jump to

Keyboard shortcuts

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