Skip to content

Commit

Permalink
Merge pull request #8 from modulovalue/dev
Browse files Browse the repository at this point in the history
Changes
  • Loading branch information
ykmnkmi committed Oct 11, 2022
2 parents 4a09a04 + e559a56 commit 39c62e7
Show file tree
Hide file tree
Showing 3 changed files with 370 additions and 125 deletions.
54 changes: 52 additions & 2 deletions bin/fire.dart
@@ -1,7 +1,8 @@
import 'dart:io' show FileSystemEntity, exit;
import 'dart:io' show FileSystemEntity, ProcessResult, exit, stdout;

import 'package:fire/fire.dart';
import 'package:fire/fire.dart' show FireOutputDelegate, run_fire;
import 'package:path/path.dart' as path;
import 'package:stack_trace/stack_trace.dart' show Trace;

Future<void> main(
final List<String> args,
Expand All @@ -19,10 +20,59 @@ Future<void> main(
args: [
if (args.isNotEmpty) ...args.sublist(1, args.length),
],
output: _FireOutputDelegateImpl(
output: stdout.writeln,
),
);
} else {
print("'" + file_path + "' not found or isn't a file.");
exit(2);
}
}
}

class _FireOutputDelegateImpl implements FireOutputDelegate {
final void Function(String) output;

const _FireOutputDelegateImpl({
required this.output,
});

@override
void output_error(
final Object payload,
final StackTrace stack_trace,
) {
output(payload.toString());
output(Trace.format(stack_trace));
}

@override
void output_string(
final String str,
) {
output(str);
}

@override
void output_compiler_output(
final Iterable<String> values,
) {
for (final line in values) {
output(line);
}
}

@override
void redirect_process(
final ProcessResult result,
) {
// TODO https://stackoverflow.com/questions/33251129/what-is-the-best-way-to-stream-stdout-from-a-process-in-dart
if (result.stdout != null) {
output(result.stdout.toString().trimRight());
}
if (result.stderr != null) {
output(result.stderr.toString().trimRight());
}
}
}

0 comments on commit 39c62e7

Please sign in to comment.