Documentation ¶
Overview ¶
Package pflagutil contains helper types and functions for the spf13/pflag and spf13/cobra packages regarding flags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var TimeDefaultLayout = "Jan 02 15:04"
TimeDefaultLayout is the layout used when showing a Time flag value in the program's helper text.
Functions ¶
func TimeRangeCompletion ¶
TimeRangeCompletion is a completion function for the TimeRange flag type, and is meant to be registered into a Cobra command object.
Types ¶
type Time ¶
type Time struct { Now bool // contains filtered or unexported fields }
Time is a pflag.Value-compatible type for allowing datetimes to be used in flags. The fuzzytime package is used to parse the user-provided flag string value.
func (*Time) Set ¶
Set attempts to parse the string as a time.Time and updates its internal state on success, or returns a parsing error if it fails.
func (*Time) String ¶
String returns a formatted string of the underlying time. If the Now field has been set, the string literal "now" is returned instead.
func (*Time) Time ¶
Time returns the time.Time value. If the Now field is set, time.Now() is returned instead.
type TimeRange ¶
type TimeRange timeutil.TimeSpanShorthand
TimeRange is a pflag.Value-compatible type for allowing time span shorthand enumeration to be used in flags.
func NewTimeRangePtr ¶
func NewTimeRangePtr(shorthand timeutil.TimeSpanShorthand) *TimeRange
NewTimeRangePtr returns a pointer to a new TimeRange instance.
func (*TimeRange) Set ¶
Set attempts to parse the string as a timeutil.TimeSpanShorthand and updates its internal state on success, or returns a parsing error if it fails.
func (*TimeRange) TimeSpanShorthand ¶
func (r *TimeRange) TimeSpanShorthand() timeutil.TimeSpanShorthand
TimeSpanShorthand returns the underlying timeutil value.