args.d | a command line argument and config file parser

H. S. Teoh via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Wed Aug 2 08:54:43 PDT 2017


On Wed, Aug 02, 2017 at 07:29:42AM +0000, Robert burner Schadek via Digitalmars-d-announce wrote:
> On Tuesday, 1 August 2017 at 17:46:57 UTC, H. S. Teoh wrote:
[...]
> > There's also UDAs for optionally flattening a nested struct, so that
> > internally I can have separate structs for configuring each module,
> > but the main program combines all of them into a single flattened
> > struct, so that to the user all the options are top-level (can
> > specify "outfile=..." instead of "backend.outputFilename=..."). The
> > user shouldn't need to know how the program is organized internally,
> > after all, yet I can still properly encapsulate configuration
> > parameters relevant to only that module, thereby avoiding spaghetti
> > dependencies of modules on a single global configuration struct.
> 
> I thought about that as well, but didn't do it because if found:
> 
> --mysql.ipAddress      Type: string   default: localhost       Help:
> --redis.ipAddress      Type: string   default: localhost       Help:
> 
> looks and works just awesome.
> At least better than --mysqlipAddress and --redisipAddress.

Well, yeah, flattening is optional in my code, so I'd only use that when
the constituent structs have unique field names.  Otherwise I'd just
leave them nested, which also works.


T

-- 
Shin: (n.) A device for finding furniture in the dark.


More information about the Digitalmars-d-announce mailing list