extensions

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package extensions provides extensions to the github.com/spf13/pflag package.

TODO: expose pflag string_array and []byte as base64

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteSize

func ByteSize(name string, defaultValue uint64, usage string) *uint64

ByteSize defines an uint64 flag with the specified name, default value, and usage string.

The return value is the address of an uint64 variable that stores the value of the flag.

func ByteSizeP

func ByteSizeP(name, shorthand string, defaultValue uint64, usage string) *uint64

ByteSizeP is like ByteSize, but accepts a shorthand letter that can be used after a single dash.

func ByteSizeVar

func ByteSizeVar(p *uint64, name string, defaultValue uint64, usage string)

ByteSizeVar defines a byte-size flag wih name, default value and usage string. The flag is set on the default pflag.CommandLine flagset.

The flag value is stored at address p.

func ByteSizeVarP

func ByteSizeVarP(p *uint64, name, shorthand string, defaultValue uint64, usage string)

ByteSizeVarP is like ByteSize, and takes a shorthand for the flag name.

func Count

func Count(name string, defaultValue int, usage string) *int

Count defines a count flag with specified name, default value, and usage string. The return value is the address of an int variable that stores the value of the flag. A count flag will add 1 to its value evey time it is found on the command line

func CountP

func CountP(name, shorthand string, defaultValue int, usage string) *int

CountP is like Count only takes a shorthand for the flag name.

func CountVar

func CountVar(p *int, name string, defaultValue int, usage string)

CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set

func CountVarP

func CountVarP(p *int, name, shorthand string, defaultValue int, usage string)

CountVarP is like CountVar only take a shorthand for the flag name.

Types

type ByteSizeValue

type ByteSizeValue uint64

ByteSizeValue is used to pass human-readable byte sizes as flags.

func NewByteSizeValue

func NewByteSizeValue(defaultValue uint64, p *uint64) *ByteSizeValue

NewByteSizeValue builds a ByteSizeValue.

func (ByteSizeValue) MarshalFlag

func (b ByteSizeValue) MarshalFlag() (string, error)

MarshalFlag implements go-flags Marshaller interface

func (*ByteSizeValue) Set

func (b *ByteSizeValue) Set(value string) error

Set the value of this bytesize (pflag value interfaces)

func (ByteSizeValue) String

func (b ByteSizeValue) String() string

String method for a bytesize (pflag value and stringer interface)

func (*ByteSizeValue) Type

func (b *ByteSizeValue) Type() string

Type returns the type of the pflag value (pflag value interface)

func (*ByteSizeValue) UnmarshalFlag

func (b *ByteSizeValue) UnmarshalFlag(value string) error

UnmarshalFlag implements go-flags Unmarshaller interface

type CountValue

type CountValue int

CountValue is used to pass increment/decrement counts as flags.

func NewCountValue

func NewCountValue(defaultValue int, p *int) *CountValue

func (*CountValue) Set

func (i *CountValue) Set(s string) error

func (*CountValue) String

func (i *CountValue) String() string

func (*CountValue) Type

func (i *CountValue) Type() string

Jump to

Keyboard shortcuts

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