Files
sdk/tools/apps/update_homebrew/bin/generate.dart
T
Kevin Moore d908743de1 update_homebrew: initial cleanup
Before fixing https://github.com/dart-lang/homebrew-dart/issues/58

Change-Id: Id09065c9a732d0eb4268f2667ff1bfea635d0922
Reviewed-on: https://dart-review.googlesource.com/c/88900
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
2019-01-10 13:05:58 +00:00

55 lines
1.5 KiB
Dart

// Copyright (c) 2014, 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:path/path.dart' as p;
import 'package:stack_trace/stack_trace.dart';
import 'package:update_homebrew/update_homebrew.dart';
void main(List<String> args) async {
final parser = ArgParser()
..addOption('revision', abbr: 'r')
..addOption('channel', abbr: 'c', allowed: supportedChannels);
final options = parser.parse(args);
final revision = options['revision'] as String;
final channel = options['channel'] as String;
if ([revision, channel].contains(null)) {
print(
"Usage: generate.dart -r revision -c channel <path_to_existing_dart.rb>");
exitCode = 1;
return;
}
if (options.rest.length != 1) {
print("Pass in the path to an existing '$dartRbFileName' file.");
exitCode = 1;
return;
}
final existingDartRb = options.rest.single;
var file = File(existingDartRb);
if (!file.existsSync()) {
print("Expected '$existingDartRb' to exist.");
exitCode = 1;
return;
}
if (p.basename(existingDartRb) != dartRbFileName) {
print("Expected provided path to end with '$dartRbFileName'.");
exitCode = 1;
}
await Chain.capture(() async {
await writeHomebrewInfo(channel, revision, file.parent.path);
}, onError: (error, chain) {
print(error);
print(chain.terse);
exitCode = 1;
});
}