run method

  1. @override
void run(
  1. List<String> args,
  2. Map<String, dynamic> flags
)

Run defines what code should be ran when this command is executed.

Implementation

@override
void run(List<String> args, Map<String, dynamic> flags) {
  if (args.isEmpty) {
    LogService.error("You must provide a feature name.");
    return;
  }

  if (args.length > 1) {
    LogService.error(
        "The feature name must be separated by '_', for example create_person");
    return;
  }

  String name = args.first;
  bool hasProvider = true;

  if (flags.containsKey('no-provider')) {
    hasProvider = false;
  }

  Feature.create(featureName: name, hasProvider: hasProvider);
  Feature.addPageToRoute(featureName: name);
}