configCommandHandler static method

Future<void> configCommandHandler(
  1. ArgResults argResult
)

Implementation

static Future<void> configCommandHandler(ArgResults argResult) async {
  final templatePath = argResult['dir'];
  final defaultName = argResult['name'];

  final config = await Config.fromFile();

  if (templatePath == null && defaultName == null) {
    print('');
    ColoredLog.white('Current Configuration :');
    ColoredLog('${config.templatePath}', name: 'Current template directory');
    ColoredLog('${config.defaultModuleName}', name: 'Default module name');
    print('');

    if (templatePath == null && defaultName == null) {
      ColoredLog.yellow(
        'To update the template directory use the below command',
      );
      ColoredLog('⚪️ templify config -d "TEMPLATE DIRECTORY"');
      ColoredLog('⚪️ templify config --dir "TEMPLATE DIRECTORY"');
      print('');
      ColoredLog.yellow(
        'To update the defaultTemplateModule name use the below command',
      );
      ColoredLog('⚪️ templify config -n "TEMPLATE MODULE NAME"');
      ColoredLog('⚪️ templify config --name "TEMPLATE MODULE NAME"');
      print('');
    } else {
      await Config.save(
        templatePath: config.templatePath,
        defaultName: config.defaultModuleName,
      );
    }
    return;
  }

  await Config.save(
    templatePath: templatePath,
    defaultName: defaultName,
  );
}