Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: --output flag #169

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion bin/scip_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import 'package:scip_dart/src/version.dart';

Future<void> main(List<String> args) async {
final result = (ArgParser()
..addOption(
'output',
abbr: 'o',
defaultsTo: 'index.scip',
help:
'The output file to write the index to. Use "-" to write to stdout',
Comment on lines +17 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a use case for outputting to stdout? given the potential size and usage of these files, I'm curious how this might be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use SCIP internally for some stuff, and we sometimes have to save to a file just to read it straight back in to parse it. This way we can skip the write to disk

)
..addFlag(
'performance',
aliases: ['perf'],
Expand Down Expand Up @@ -71,5 +78,10 @@ Future<void> main(List<String> args) async {

final index = await indexPackage(packageRoot, packageConfig, pubspec);

File('index.scip').writeAsBytesSync(index.writeToBuffer());
if (result['output'] as String == '-') {
stdout.add(index.writeToBuffer());
stdout.flush();
} else {
File(result['output'] as String).writeAsBytesSync(index.writeToBuffer());
}
}