flagvar

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

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

Go to latest
Published: Nov 11, 2016 License: Apache-2.0 Imports: 2 Imported by: 2

README

flagvar GoDoc

Extended flag type variables for Go

Package flagvar extends the default flag package with some well known types, which are not part of the package.

See the godoc for example usage and documentation.

Documentation

Overview

Package flagvar extends the standard flag package with some well-known types, that are not available there.

Example usage:

package main

import (
	"flag"
	"fmt"

	"github.com/Bo0mer/flagvar"
)

var (
	tags       flagvar.Array
	attributes flagvar.Map
)

func init() {
	flag.Var(&tags, "tag", "Tag to add.")
	flag.Var(&attributes, "attribute", "Attribute to add.")
}

func main() {
	flag.Parse()

	fmt.Println("tags provided:", tags)
	fmt.Println("attributes provided:", attributes)

	// When started with:
	// -tag=1 -tag=2 -attribute foo:bar -attribute baz:boo
	// Outputs:
	// tags provided: [1 2]
	// attributes provided: map[foo:bar baz:boo]
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array []string

Array represents string array flag variable.

func (*Array) Set

func (a *Array) Set(value string) error

Set appends element to the array.

func (*Array) String

func (a *Array) String() string

String returns the string representation of the array.

type Map

type Map map[string]string

Map represents map[string]string flag variable.

func (*Map) Set

func (m *Map) Set(value string) error

Set adds element to the map. It must be in key:value format, otherwise error is returned.

func (*Map) String

func (m *Map) String() string

String returns the string representation of the map.

Jump to

Keyboard shortcuts

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