Skip to content

Commit

Permalink
Add shortcut Parse function
Browse files Browse the repository at this point in the history
Most common use case is calling autoflags.Define(...) followed by
flag.Parse(), so add shortcut function for this.
  • Loading branch information
Artyom Pervukhin committed Mar 1, 2017
1 parent 8b3cacf commit 250b3e9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions autoflags.go
Expand Up @@ -62,6 +62,12 @@ var (
// interface for such attributes).
func Define(config interface{}) { DefineFlagSet(flag.CommandLine, config) }

// Parse is a shortcut for:
//
// autoflags.Define(&args)
// flag.Parse()
func Parse(config interface{}) { Define(config); flag.Parse() }

// DefineFlagSet takes pointer to struct and declares flags for its flag-tagged
// fields on given FlagSet. Valid tags have one of the following formats:
//
Expand Down

0 comments on commit 250b3e9

Please sign in to comment.