Skip to content

jad-b/flagit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flagit

Auto-propulate Go structs into command-line flags.

Allows these:

type ChipotleOrder struct {
    Rice                string
    Beans               string
    FajitaVegetables    boolean
    Meat                string
    Salsa               []string
    Corn                boolean
    SourCream           boolean
    Cheese              boolean
    Guacamole           boolean
}

type PlacedOrder struct {
    ChipotleOrder
    Address
    TimeReady     time.Time
}

...to accept these:

$ ./main -placed-order \
    -rice brown \
    -beans pinto \
    -fajita-vegetables \
    -meat barbacoa \
    -salsa mild,hot \
    -guacamole \
    -time-ready 7:56PM \
    -address 'last used'

...without you having to write all those flags yourself.

Reflection.

For a Go playground example of the required reflection to do this magic, go here: http://play.golang.org/p/4bTL5v7OSi

About

Auto-propulate Go structs into command-line flags.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages