Command line flags made simple
go get -u github.com/libgolang/propsimport ( "fmt" "github.com/libgolang/props" ) func main() { if props.IsSet("name") { fmt.Printf("My Name is %s\n", props.GetProp("name")) } else { fmt.Printf("No name given\n") } }- Does not require pre-defining properties. It dynamically figures out properties based on
os.Args - Does no require 3rd party libraries
- Just three functions
GetProp,IsSetandGetArgs
- Arguments with two dashes and an equal sign are interpreted as properties with a value. e.g.:
--prop-name=value - Arguments with two dashes and NO equal sign will interpret the next argument as a value. If no argument is followed by the property, then it will have an empty value. e.g.:
--prop-name valuethenGetProp("prop-name"): "value"and--prop-name --some-other-propertythenGetProp("prop-name"): "" - Arguments with one dash are interperted as Flags. If a value is passed to the flag it is igned and used as an argument in
GetArgs(). e.g.:-pthenIsSet("p") : true - Any argument not part of a flag or a property is added to the argument list and they can be retrived by calling
GetArgs().