carve function

void carve({
  1. required String name,
  2. required ArgResults argResults,
})

This method is the main api It is called from the bin directory, which is used to define all needed commands

This method calls a different instance Carvers depending on the passed command name is the name of the command argResults are the results of the invocation of this command with defined options, flags, etc.

Implementation

void carve({required String name, required ArgResults argResults}) {
  final CommandType type = from(name);
  switch (type) {
    case CommandType.model:
      final ModelCarver modelCarver = ModelCarver();
      modelCarver.carveModel(argResults);
      break;
    case CommandType.page:
      final PageCarver pageCarver = PageCarver();
      pageCarver.carvePage(argResults);
      break;
    case CommandType.stateful:
      final StatefulCarver statefulCarver = StatefulCarver();
      statefulCarver.carveStateful(argResults);
      break;
    case CommandType.stateless:
      final StatelessCarver statelessCarver = StatelessCarver();
      statelessCarver.carveStateless(argResults);
      break;
    default:
      throw UnsupportedError('Unsupported CommandType: ' + type.toString());
  }
}