blob: 1208ce6c83799de987c8b0afc130e465fc558aba [file] [log] [blame]
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'package:args/args.dart';
import 'package:blast_repo/src/top_level.dart';
import 'package:blast_repo/src/utils.dart';
import 'package:io/io.dart';
import 'package:stack_trace/stack_trace.dart';
Future<void> main(List<String> args) async {
final parser = ArgParser()
help: "Don't delete the temporary repo clone.",
negatable: false,
help: 'Optionally list the specific tweaks to run (defaults to all '
'applicable tweaks).',
allowed: =>,
valueHelp: 'tweak1,tweak2')
aliases: ['pr-reviewer'],
valueHelp: 'github-id',
help: 'Specify the GitHub handle for the desired reviewer.',
abbr: 'h',
negatable: false,
help: 'Prints out usage and exits.',
void printUsage() {
print('Usage: $packageName <options> [org/repo]\n');
print('\navailable tweaks:');
for (var tweak in allTweaks) {
print(' ${}: ${tweak.description}');
final ArgResults argResults;
try {
argResults = parser.parse(args);
} on FormatException catch (e) {
exitCode = ExitCode.usage.code;
if (argResults['help'] as bool || {
final slug =;
final keepTemp = argResults['keep-temp'] as bool;
final prReviewer = argResults['reviewer'] as String?;
final explicitTweakIds = argResults['tweaks'] as List<String>;
final explicitTweaks = explicitTweakIds.isEmpty
? null
: explicitTweakIds
.map((id) => allTweaks.firstWhere((t) => == id))
try {
await runFix(
slug: slug,
deleteTemp: !keepTemp,
tweaks: explicitTweaks,
prReviewer: prReviewer,
} catch (error, stack) {
final chain = Chain.forTrace(stack);
print('Error type: ${error.runtimeType}');
exitCode = 1;