flagtypes

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package flagtypes provides types that implement the pflags.Value interface for converting command line flags to objects.

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GLog

func GLog(flags *pflag.FlagSet)

GLog binds the log flags from the default Google "flag" package into a pflag.FlagSet.

Types

type Addr

type Addr struct {
	// Specified by the caller
	DefaultScheme string
	DefaultPort   int
	AllowPrefix   bool

	// If Set has been invoked this value is true
	Provided bool
	// The exact value provided on the flag
	Value string

	// A URL that represents the user input. The Host field is guaranteed
	// to be set if Provided is true
	URL *url.URL
	// The hostname or IP portion of the user input
	Host string
	// The port portion of the user input. Will be 0 if no port was found
	// and no default port could be established.
	Port int
}

Addr is a flag type that attempts to load a host, IP, host:port, or URL value from a string argument. It tracks whether the value was set and allows the caller to provide defaults for the scheme and port.

func (Addr) Default

func (a Addr) Default() Addr

Default creates a new Address with the value set

func (*Addr) Set

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

Set attempts to set a string value to an address

func (*Addr) String

func (a *Addr) String() string

String returns the string representation of the Addr

func (*Addr) Type

func (a *Addr) Type() string

Type returns a string representation of what kind of value this is

type IP

type IP net.IP

IP adapts net.IP for use as a flag.

func (*IP) Set

func (ip *IP) Set(value string) error

func (IP) String

func (ip IP) String() string

func (*IP) Type

func (ip *IP) Type() string

Type returns a string representation of what kind of argument this is

type IPNet

type IPNet net.IPNet

IPNet adapts net.IPNet for use as a flag.

func DefaultIPNet

func DefaultIPNet(value string) IPNet

func (*IPNet) Set

func (ipnet *IPNet) Set(value string) error

func (IPNet) String

func (ipnet IPNet) String() string

func (*IPNet) Type

func (ipnet *IPNet) Type() string

Type returns a string representation of what kind of argument this is

type StringList

type StringList util.StringList

StringList is a type overriding util.StringList to provide the Type() method in order to fulfill the spf13/pflags.Value interface. It is a util.StringList in order to be compatible with util.CompileRegexps. util.CompileRegexps should probably be modified to accept a direct []string to make it more easily reusable, but that has to happen first and then this code can be tidied up.

func (*StringList) Set

func (sl *StringList) Set(value string) error

Set takes a string, splits it on commas, ensures there are no empty parts of the split, and appends them to the receiver.

func (*StringList) String

func (sl *StringList) String() string

String returns the string representation of the StringList

func (*StringList) Type

func (sl *StringList) Type() string

Type returns a string representation of what kind of argument this is

Jump to

Keyboard shortcuts

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