parseConfigArgs<T> function

Future<T> parseConfigArgs<T>(
  1. List<String> args,
  2. Serializer<T> serializer,
  3. {T defaultConf,
  4. bool mustLoad = false}
)

Implementation

Future<T> parseConfigArgs<T>(List<String> args, Serializer<T> serializer,
    {T defaultConf, bool mustLoad = false}) async {
  // Get the config file name from command line argument
  final parser = ArgParser();
  parser.addOption('config', abbr: 'c', help: 'Config file');
  ArgResults results = parser.parse(args);
  String configFile = results['config'];
  if (configFile == null) {
    if (mustLoad) {
      throw Exception("Config file not specified in command line argument.");
    }
    return defaultConf;
  }

  return parseConfigFile(configFile, serializer);
}