simpleconfig ~mihails-strasuns-patch-1
Simple utility to combine CLI args and config file into single config
To use this package, run the following command in your project's root directory:
						Manual usage
						
						Put the following dependency into your project's dependences section:
					
Library primarily intended to help quickly write small command-line tools. Parses command-line arguments and configuration file and stores result into provided D struct instance.
Example
void main ()
{
    import simpleconfig;
    struct Config
    {
        @cli
        int value;
        @cli("flag|f") @cfg("flag")
        string anothervalue;
        @cfg("some ratio")
        double ratio;
        void finalizeConfig ()
        {
        }
    }
    Config config;
    readConfiguration(config);
}
This snippet will do the following:
- Check standard locations for the current platform for the config file named
  appname.cfg. If found, parse it and initializeconfig.anothervaluefromflagentry andconfig.rationfromsome ratioentry.
- Iterate through command-line arguments. If --valueargument is found, it will be written toconfig.value(usingstd.conv.tofor conversion). If either--flagor-farguments are found, it will be written toconfig.anothervalue.
- Call config.finalizeConfigif defined for a given struct.
If value is set both by config file and command-line argument, the latter takes priority.
Config files
Currently config file is named appname.cfg and uses simple key-value format:
key = value
another key = " value that starts with a whitespace"
The following locations are checked for config file presence:
1) Current working directory
2) Same folder as the executable
3) $XDG_CONFIG_HOME (Posix) or %LOCALAPPDATA% (Windows)
- ~mihails-strasuns-patch-1 released 4 years ago
- mihails-strasuns/d-simpleconfig
- BSL
- Copyright © 2018, Mihails Strasuns
- Authors:
- Dependencies:
- none
- Versions:
- 
						
 Show all 9 versions1.0.0 2021-Mar-06 0.3.0 2019-Jun-09 0.2.1 2019-Feb-01 0.2.0 2019-Jan-03 0.1.0 2018-Dec-27 
- Download Stats:
- 
						- 
								0 downloads today 
- 
								3 downloads this week 
- 
								3 downloads this month 
- 
								227 downloads total 
 
- 
								
- Score:
- 1.1
- Short URL:
- simpleconfig.dub.pm