flags

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package flags provides a wrapper around pflag that provides a consistent way to access configuration values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flag

type Flag[T any] struct {
	// contains filtered or unexported fields
}

func Bool

func Bool(flags *pflag.FlagSet, name string, value bool, usage string) Flag[bool]

Bool defines a bool flag with specified name, default value, and usage string.

func BoolP

func BoolP(flags *pflag.FlagSet, name, shorthand string, value bool, usage string) Flag[bool]

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

func String

func String(flags *pflag.FlagSet, name string, value string, usage string) Flag[string]

String defines a string flag with specified name, default value, and usage string.

func StringP

func StringP(flags *pflag.FlagSet, name, shorthand string, value string, usage string) Flag[string]

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

func (Flag[T]) Changed

func (f Flag[T]) Changed() bool

Changed returns true if the flag was explicitly set during Parse() and false otherwise

func (Flag[T]) Get

func (f Flag[T]) Get() T

Get returns the value of the flag.

Jump to

Keyboard shortcuts

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