cmdparse

package module
v0.0.0-...-f14c524 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2017 License: MIT Imports: 2 Imported by: 1

README

Cmdparse GoDoc

A utility library that helps emulate command line parsing.

Usage

License

All source code in this repository is license under the term of the MIT

Documentation

Index

Constants

View Source
const (
	// DefaultQuotes are the normal quote characters for a command line
	DefaultQuotes = "\"'`"
)

Variables

View Source
var (
	// ErrNoQuoteTerm is returned when no terminating quote is found in a line.
	ErrNoQuoteTerm = errors.New("no matching terminating quote found")
)

Functions

func Bytes

func Bytes(line, quotes []byte) (s []string, err error)

Bytes parses a line from bytes into a slice of strings. If a character from quotes is encountered then it will add add all into a string until the matching character is found. If not matching terminating quote is found an error is returned.

func Line

func Line(line string) (args []string, err error)

Line is similar to LineWithQuotes except it uses DefaultQuotes for the quote characters. Like LineWithQuotes, Runes, and Bytes it will return as error if a quote is encountered but no match is found later.

func LineWithQuotes

func LineWithQuotes(line, quotes string) (args []string, err error)

LineWithQuotes parses a line line a comand line parser would. It accepts a string of characters that act as quotes used to provided arguments that contain spaces and words.

func Runes

func Runes(line, quotes []rune) (s []string, err error)

Runes parses a line from runes into a slice of strings. If a character from quotes is encountered then it will add add all into a string until the matching character is found. If no matching terminating quote is found an error is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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