runTranscriptViewer function

Future<int> runTranscriptViewer(
  1. List<String> args
)

命令行入口。bin/transcripts.dart 直接 await runTranscriptViewer(args)

Implementation

Future<int> runTranscriptViewer(List<String> args) async {
  if (args.isEmpty) {
    stdout.writeln(transcriptViewerUsage);
    return 0;
  }

  final cmd = args.first;
  final opts = _parseOptions(args.sublist(1));
  final store = FileReportStore(Directory(opts['store'] ?? './reports'));

  switch (cmd) {
    case 'list':
      return _cmdList(store, opts);
    case 'show':
      return _cmdShow(store, opts);
    case 'diff':
      return _cmdDiff(store, opts);
    case 'export':
      return _cmdExport(store, opts);
    case '-h':
    case '--help':
      stdout.writeln(transcriptViewerUsage);
      return 0;
    default:
      stderr.writeln('unknown command: $cmd');
      stdout.writeln(transcriptViewerUsage);
      return 2;
  }
}