config icon indicating copy to clipboard operation
config copied to clipboard

Add command line args processing

Open cbndr opened this issue 2 years ago • 1 comments

A concern I have is handling command line args. I personally have the pref to this order of precedence for configuration:

  • config file
  • can be overridden by env vars
  • can be overwritten by command line args

Would it make sense to add a bit of code for this, or how would you propose to handle this use case?

I would propose to use separate tags, as normally not all config items should be configurable via command line and the arg names should be different.

cbndr avatar Jul 07 '21 07:07 cbndr

https://pkg.go.dev/flag#pkg-overview

The stdlib can already bind pointers to flags, that’s handled every usecase I’ve need so far. It seems it also handles your usecases of

  • not every config value exists in the command line
  • the arg names can be different

I don’t want to dismiss your suggestion though - could you write some pseudocode showing what you would want?

JeremyLoy avatar Jul 09 '21 12:07 JeremyLoy