> I really like the idea of specifying flags in flagfiles and environment 
variables. 

For *using environment variables with flags*, take a look at 
https://github.com/go-easygen/easygen/blob/master/test/commandlineFlag.ref
which has not extra dependencies but the go native flag pkg. 

All you need is to provide a file like this:
https://github.com/go-easygen/easygen/blob/master/test/commandlineFlag.yaml

For *using flagfiles and environment variables*, take a look at 
https://github.com/suntong/lang/tree/master/lang/Go/src/sys/CLI#027-global-optiongo

Options:

  -h, --help              display help information
  -c, --config[=1.json]   config
  -H, --host[=$HOST]      host addr
  -p, --port              listening port

If you like to go down that route, take a further look at 

   - A cookbook on how to jump-start a cli based command line handling 
   program 
   <https://github.com/go-easygen/easygen/blob/master/cli-project.md#cookbook>

under https://github.com/go-easygen/easygen#details



On Sunday, June 25, 2017 at 6:31:39 PM UTC-4, Ivan Vučica wrote:
>
> Hello, 
>
> Since glog's readme recommends firing off an email to golang-nuts to 
> report possible issues, here I go. 
>
> I really like the idea of specifying flags in flagfiles and 
> environment variables. This Go package seems to let me do that, while 
> staying pretty much API-compatible with the standard flag package: 
>   github.com/namsral/flag 
>
> However, if I start using it as a replacement for "flag" package, the 
> program (naturally) only recognizes flags specified using namsral's 
> flag package. This means that the flags defined in the glog package 
> are not visible to namsral's package, and thus are not visible to the 
> user. 
>
> Since variables backing the glog flags are not part of the public 
> interface, I can't, really, write a nice wrapper. Instead I could 
> write a wrapper that reads the values from namsral/flags-created 
> variables, and uses flag.Set() to set them into Go's flag package, and 
> then calls Go's flag.Parse(). 
>
> That feels bad. Does anyone have any suggestions on alternative 
> approaches? Could the variables backing the flags be exposed, so I can 
> do my own calls to flag.BoolVar()/flag.Var()? 
>
> Would it make sense to extend Go's flag package to use the environment 
> and flagfiles in addition to just command line arguments? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to