startConfig function

void startConfig(
  1. String path
)

Initializes the supplied configuration from path

Implementation

void startConfig(String path) {
  if (path.isEmpty) {
    error(
        'Pass the trconfig.yaml path to --config, or add `fts` to pubspec.yaml');
    exit(1);
  }
  var f = File(path);
  if (!f.existsSync()) {
    error('Error: $path config file not found');

    /// ask to create from template.
    var useCreateTemplate = confirm(
        yellow(
            'Do you wanna create the template (trconfig.yaml) in the current directory?'),
        defaultValue: true);
    if (!useCreateTemplate) {
      var m1 = grey('${CliConfig.cliName} run', background: AnsiColor.black);
      var m2 = grey('${CliConfig.cliName} -h', background: AnsiColor.black);
      var msg =
          '${white('Use', bold: false)} $m1 with a configuration file or see $m2 for more help.';
      print(msg);
      // trace(' trcli again with a configuration file or check trcli -h for more help.');
      exit(0);
    } else {
      /// create template!
      createSampleContent();
    }
  } else {
    loadEnv(
      path: path,
    );
  }
}