main function

void main(
  1. List<String> arguments
)

Implementation

void main(List<String> arguments) async {
  final parser = ArgParser()
    ..addOption('file', abbr: 'f')
    ..addOption('directory', abbr: 'd')
    ..addOption('output-directory', abbr: 'o')
    ..addOption('sdk-name', abbr: 's')
    ..addOption('compile-kind',
        abbr: 'k',
        defaultsTo: 'bundle',
        allowed: ['bundle', 'dart', 'flutter', 'sdk']);
  var argResults = parser.parse(arguments);
  var kind = argResults['compile-kind'];
  if (kind == 'bundle') {
    var file = argResults['file'];
    if (file == null || !File(file).existsSync()) {
      print('file is required, please pass as absolute path');
      exit(1);
    }
    _printResult(await dsl.parseFile(file));

  } else if (kind == 'dart') {
    var dirString = argResults['directory'];
    Directory dir;
    if (dirString == null || !(dir = Directory(dirString)).existsSync()) {
      print('directory is not valid, please pass as absolute path');
      exit(1);
    }
    _printResult(await binding.parseDir(dir));
  } else if (kind == 'flutter') {
    var dir = argResults['directory'];
    if (dir == null || !(Directory(dir)).existsSync()) {
      print('directory is not valid, please pass as absolute path');
      exit(1);
    }
    await binding.parseFlutter(dir);
  } else if (kind == 'sdk'){
    var file = argResults['file'];
    var sdkName = argResults['sdk-name'];
    var outputDir = argResults['output-directory'];
    if (file == null || !File(file).existsSync()){
      print('file is required, please pass as absolute path');
      exit(1);
    }
    var _output = 'sdk';
    if(outputDir?.isNotEmpty == true){
      _output = outputDir;
    }
    await binding.parseSdkFile(sdkName, file, _output);
  }
}