cliparse

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package cliparse converts a command line string into CommandLine program and args struct

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commandline

type Commandline struct {
	ProgramPath string
	Args        []string
}

Commandline represents a program and arguments.

type Parser

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

Parser is a basic command line parser. Command lines are converted to Commandline instance, containing the program and an array or arguments. Parser handles string expansion with environment variables and respects quotation the parse can also glob wildcards in arguments.

func NewParse

func NewParse() *Parser

NewParse creates a new parser.

func (*Parser) Parse

func (p *Parser) Parse(commandLine string, args ...string) (c *Commandline, err error)

Parse parses a command line or returns an error The command line may contain space separated args. Additional can also be provided.

func (*Parser) WithGlob

func (p *Parser) WithGlob(glob func(string) ([]string, error)) *Parser

WithGlob adds a glob function too the parser, this expands any wildcard arguments.

Jump to

Keyboard shortcuts

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