stringlist

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2019 License: MIT Imports: 2 Imported by: 0

README

GoDoc

stringlist

Package stringlist implements a custom "stringlist" flag for Go.

Documentation

Overview

Package stringlist implements a custom "stringlist" flag It accepts comma separated values and repeated flag occurrence. Leading and trailing whitespace will be trimmed.

Usage:

var (
	myFlag stringlist.Value
)

func init() {
	flag.Var(&myFlag, "myflag", "a list of strings")
}

Or:

var (
	myFlag = stringlist.Flag("myflag", "a list of strings")
)

func foo() {
	for _, i = range *myFlag {
		// note: you need to dereference the slice
	}
}

If you invoke it with:

--myflag a,b --myflag c --myflag "c, d"

myFlag will contain: []string{"a", "b", "c", "d"}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Value

type Value []string

Value implements flag.Value

func Flag

func Flag(name string, usage string) *Value

Flag returns a stringlist flag

func (*Value) Set

func (v *Value) Set(args string) error

Set implements the flag.Value interface

func (*Value) String

func (v *Value) String() string

Jump to

Keyboard shortcuts

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