parms

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: GPL-2.0, GPL-2.0-or-later Imports: 2 Imported by: 0

README

Package flags parses NAME[= ]VALUE options from command arguments.


© 2015-2016 Platina Systems, Inc. All rights reserved. Use of this source code is governed by this BSD-style LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type Aliases

type Aliases map[string]string

type ByName

type ByName map[string]string

type Parms

type Parms struct {
	ByName ByName
	// contains filtered or unexported fields
}

func New

func New(args []string, parms ...interface{}) (*Parms, []string)

Define and parse {NAME{=|' '}VALUE} parameters from command arguments, e.g.

parm, args := parms.New([]string{ "-a", "A", "-b=B", "something"},
	"-a", "-b", "-c")

results in

parm.ByName["-a"] == "A"
parm.ByName["-b"] == "B"
parm.ByName["-c"] == ""
args == []string{"something"}

Parmeters may be defined with strings or string slices that include aliases of the first entry, e.g.

parm, args := parms.New([]string{"-color", "blue},
	"-a", "-b", []string{"-c", "-color", "-colour"})

results in

parm.ByName["-a"] == ""
parm.ByName["-b"] == ""
parm.ByName["-c"] == "blue"
args == []string{}

func (*Parms) More

func (p *Parms) More(args []string, parms ...interface{}) []string

Define and parse more parameters from command arguments.

func (*Parms) Parse

func (p *Parms) Parse(args []string) []string

Parse predefined parameters from command arguments.

func (*Parms) Reset

func (p *Parms) Reset()

Reset all parameters.

func (*Parms) Set

func (p *Parms) Set(name, value string) error

Set will concatenate a non empty parmeter.

Jump to

Keyboard shortcuts

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