Documentation ¶
Overview ¶
Package flags adds more types of flags which satisfy the flag.Value interface.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IntRange ¶
type IntRange struct {
Value, Min, Max int
}
IntRange is used to specify an *inclusive* range for the std "flag" package. The result is stored in Value.
Example ¶
package main import ( "flag" "fmt" "github.com/aod/elver/flags" ) func main() { fs := flag.NewFlagSet("example usage of IntRange", flag.ContinueOnError) ir := flags.IntRange{Min: 0, Max: 10} fs.Var(&ir, "num", "select a number between 1 to 10") fs.Parse([]string{"-num", "6"}) fmt.Println(ir.Value) }
Output: 6
Click to show internal directories.
Click to hide internal directories.