simpleconfig 1.0.0

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.


void main ()
    import simpleconfig;

    struct Config
        int value;
        @cli("flag|f") @cfg("flag")
        string anothervalue;
        @cfg("some ratio")
        double ratio;

        void finalizeConfig ()


    Config 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 initialize config.anothervalue from flag entry and config.ration from some ratio entry.
  • Iterate through command-line arguments. If --value argument is found, it will be written to config.value (using for conversion). If either --flag or -f arguments are found, it will be written to config.anothervalue.
  • Call config.finalizeConfig if 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
1.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
Show all 9 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 221 downloads total

Short URL: