artisanGenerator function

void artisanGenerator(
  1. List<String>? arguments
)

A Calculator.

Implementation

void artisanGenerator(List<String>? arguments) {
  if (arguments!.isEmpty) {
    return Utilities().printError(
        "please complete instruction with some arguments, for help please type 'dart run arisan --help'");
  }
  String instruction = "";
  String instructionValue = "";
  String instructionDetail = "";
  bool isDetected = false;
  List<String> validInstruction = ['make', 'list'];
  List<String> validInstructionValue = [
    'controller',
    'page',
    'repository',
    'module'
  ];
  arguments.asMap().entries.map((e) {
    /*
    get first arguments
    get 0 argument from first argument
    get scound argument
    0 argument candidate
    make:
    list:
    */
    if (e.value == "--help") {
      instruction = 'help';
      isDetected = true;
    } else {
      if(e.key == 0){
        isDetected = true;
        List<String> listArgs = e.value.split(":");
        if(validInstruction.indexWhere((element) => element == listArgs[0]) == -1){
          return invalidArguments();
        }
        if(validInstructionValue.indexWhere((element) => element == listArgs[1]) == -1){
          return invalidArguments();
        }
        instruction = listArgs[0];
        instructionValue = listArgs[1];
      }else if(e.key == 1){
        instructionDetail = e.value;
      }else{
        isDetected = false;
      }
    }

  }).toList();
  if (instruction == 'help') {
    return helpGenerator();
  }
  if(instruction == "make"  && instructionDetail == ""){
    return invalidArguments();
  }
  if (isDetected == false) {
    return Utilities().printError(
        "please complete instruction with some arguments, for help please type 'dart run arisan --help'");
  }
  if(instruction == "make"){
    if(instructionValue == "controller"){
      generateSingleController(instructionDetail);
    } else if(instructionValue == 'page'){
      genereteSinglePage(instructionDetail);
    }else if(instructionValue == 'repository'){
      generateSingleRepository(instructionDetail);
    }else if(instructionValue == "module"){
      generateModule(instructionDetail);
    }
  }else if(instruction == 'list'){
     if(instructionValue == "controller"){
      generateListController();
    } else if(instructionValue == 'repository'){
      generateListRepository();
    }
  }

}