<commit_before>part of bridge.cli;

class BridgeCli extends Program {
  final Application app = new Application();
  final String _configPath;
  final bool _setProduction;

  BridgeCli(this._configPath, Shell shell, [this._setProduction])
      : super(shell) {
    app..singleton(this)..singleton(this, as: Program);
  }

  setUp() async {
    await app.setUp(_configPath);
    if (_setProduction) Environment.current = Environment.production;
    InputDevice.prompt = new Output('<cyan>=</cyan> ');
  }

  tearDown() async {
    await unwatch();
    await app.tearDown();
  }

  @override
  Future run({String bootArguments: '', stdinBroadcast, reloadPort}) {
    return super.run(
        bootArguments: bootArguments.replaceAll('--production', ''),
        stdinBroadcast: stdinBroadcast,
        reloadPort: reloadPort);
  }

  bool _watching = false;
  bool _reloading = false;
  StreamSubscription _watchSubscription;

  @Command('Watch your project files for changes')
  watch() async {
    if (_watching) {
      printWarning('Already watching!');
      return;
    }
    _watching = true;
    _watchSubscription = new Watcher(Directory.current.path)
        .events
        .listen((WatchEvent event) async {
      if (path.split(event.path).any((s) => s.startsWith('.'))) return;
      if (_reloading || path.basename(event.path).startsWith('.')) return;
      printAccomplishment('Reloading...');
      _reloading = true;
      await reload(['watch']);
    });

    printInfo('Watching files...');
  }

  @Command('Stop watching your project files for changes')
  unwatch() async {
    if (!_watching) return;
    await _watchSubscription.cancel();
    if (!_reloading) printInfo('Stopped watching files');
    _watching = false;
  }

  @Command('Build the projects client side assets using [pub build]')
  build() async {
    final buildRootDirectory = new Directory(app.config('http.server.build_root'));
    final buildDirectory = new Directory(app.config('http.server.build_root', 'build'));
    final tempDirectory = await buildRootDirectory.createTemp();

    await _run('pub', ['build', '-o', tempDirectory.path]);
    await buildDirectory.delete();

    await tempDirectory.rename(app.config('http.server.build_root', 'build'));
  }

  Future _run(String executable, List<String> arguments) async {
    printWarning('Executing: $executable ${arguments.join(' ')}');

    final process = await Process.start(executable, arguments);
    process.stdout
        .map(UTF8.decode)
        .map((s) => _colorizeOutput(executable, s))
        .listen(this.print);
    process.stderr
        .map(UTF8.decode)
        .map((s) => _colorizeOutput(executable, s))
        .listen(this.print);
    final exitCode = await process.exitCode;

    if (exitCode != 0) printDanger('Exited with exit code $exitCode');
    else printAccomplishment('Finished: $executable ${arguments.join(' ')}');
  }

  String _colorizeOutput(String executable, String line) {
    return '<gray>[<gray><cyan>$executable</cyan><gray>] ${line.trim()}</gray>';
  }
}<commit_msg>delete recursive<commit_after>part of bridge.cli;

class BridgeCli extends Program {
  final Application app = new Application();
  final String _configPath;
  final bool _setProduction;

  BridgeCli(this._configPath, Shell shell, [this._setProduction])
      : super(shell) {
    app..singleton(this)..singleton(this, as: Program);
  }

  setUp() async {
    await app.setUp(_configPath);
    if (_setProduction) Environment.current = Environment.production;
    InputDevice.prompt = new Output('<cyan>=</cyan> ');
  }

  tearDown() async {
    await unwatch();
    await app.tearDown();
  }

  @override
  Future run({String bootArguments: '', stdinBroadcast, reloadPort}) {
    return super.run(
        bootArguments: bootArguments.replaceAll('--production', ''),
        stdinBroadcast: stdinBroadcast,
        reloadPort: reloadPort);
  }

  bool _watching = false;
  bool _reloading = false;
  StreamSubscription _watchSubscription;

  @Command('Watch your project files for changes')
  watch() async {
    if (_watching) {
      printWarning('Already watching!');
      return;
    }
    _watching = true;
    _watchSubscription = new Watcher(Directory.current.path)
        .events
        .listen((WatchEvent event) async {
      if (path.split(event.path).any((s) => s.startsWith('.'))) return;
      if (_reloading || path.basename(event.path).startsWith('.')) return;
      printAccomplishment('Reloading...');
      _reloading = true;
      await reload(['watch']);
    });

    printInfo('Watching files...');
  }

  @Command('Stop watching your project files for changes')
  unwatch() async {
    if (!_watching) return;
    await _watchSubscription.cancel();
    if (!_reloading) printInfo('Stopped watching files');
    _watching = false;
  }

  @Command('Build the projects client side assets using [pub build]')
  build() async {
    final buildRootDirectory = new Directory(app.config('http.server.build_root'));
    final buildDirectory = new Directory(app.config('http.server.build_root', 'build'));
    final tempDirectory = await buildRootDirectory.createTemp();

    await _run('pub', ['build', '-o', tempDirectory.path]);
    await buildDirectory.delete(recursive: true);

    await tempDirectory.rename(app.config('http.server.build_root', 'build'));
  }

  Future _run(String executable, List<String> arguments) async {
    printWarning('Executing: $executable ${arguments.join(' ')}');

    final process = await Process.start(executable, arguments);
    process.stdout
        .map(UTF8.decode)
        .map((s) => _colorizeOutput(executable, s))
        .listen(this.print);
    process.stderr
        .map(UTF8.decode)
        .map((s) => _colorizeOutput(executable, s))
        .listen(this.print);
    final exitCode = await process.exitCode;

    if (exitCode != 0) printDanger('Exited with exit code $exitCode');
    else printAccomplishment('Finished: $executable ${arguments.join(' ')}');
  }

  String _colorizeOutput(String executable, String line) {
    return '<gray>[<gray><cyan>$executable</cyan><gray>] ${line.trim()}</gray>';
  }
}
{'fraction_non_alphanumeric': 0.14222873900293256, 'fraction_numerical': 0.0009775171065493646, 'mean_word_length': 3.6613515565679573, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '779449', 'n_tokens_mistral': 1855, 'n_tokens_neox': 1817, 'n_words': 416}