gen function

void gen(
  1. String gen, {
  2. String? projectPath,
  3. String? dir,
  4. String? domain,
  5. String? model,
})

Implementation

void gen(
  String gen, {
  String? projectPath,
  String? dir,
  String? domain,
  String? model,
}) {
  if (gen == '--genall') {
    if (projectPath != null) {
      genDir(projectPath);
      genDoc(projectPath);
      genLib(gen, projectPath);
      genTest(projectPath, ednetCoreModel);
      // genWeb(projectPath);
      final gitignore = genFile('${projectPath}/.gitignore');
      genGitignore(gitignore);
      final readme = genFile('${projectPath}/README.md');
      genReadme(readme);
      final pubspec = genFile('${projectPath}/pubspec.yaml');
      genPubspec(pubspec);
    } else {
      throw ArgumentError('projectPath is required when calling --genall');
    }
  } else if (gen == '--gengen') {
    if (projectPath != null) {
      genLib(gen, projectPath);
    } else if (dir != null && domain != null && model != null) {
      createDomainModelFromYaml(dir: dir, domain: domain, model: model);
      if (outputDir != null) {
        genLib(gen, outputDir!);
      } else {
        throw ArgumentError(
          'outputDir is required when calling --gengen with dir, domain,'
          ' and model arguments',
        );
      }
    } else {
      throw ArgumentError(
        'projectPath or dir, domain, and model arguments are required '
        'when calling --gengen',
      );
    }
  } else {
    throw ArgumentError('valid gen argument is either --genall or --gengen');
  }
}