main function Null safety

Future main(
  1. List<String> arguments
)

The entry point of RSP compiler.

Implementation

Future main(List<String> arguments) async {
  final env = new _Environ();
  if (!_parseArgs(arguments, env))
    return;

  final stats = new _Stats();

  Future compile(String name)
  => compileFile(name, encoding: env.encoding, verbose: env.verbose,
          lineNumber: env.lineNumber, newer: env.newer,
          onCompile: stats.onCompile);

  for (final String name in env.sources) {
    final dir = new Directory(name);
    if (await dir.exists()) {
      await for (final fse in dir.list(recursive: true)) {
        final path = fse.path;
        if (path.endsWith(".rsp.html")
        && await FileSystemEntity.isFile(path)) {
          try {
            await compile(path);
          } catch (ex, st) {
            print("Unable to compile $path: $ex\n$st");
          }
        }
      }
    } else {
      compile(name);
    }
  }

  stats.printSummary();
}