platform-cli/bin/angel.dart

54 lines
1.4 KiB
Dart
Raw Normal View History

2016-07-05 21:20:01 +00:00
#!/usr/bin/env dart
2017-02-01 22:56:04 +00:00
library demon.tool;
2016-07-05 21:19:02 +00:00
2016-09-14 04:33:28 +00:00
import "dart:io";
import "package:args/command_runner.dart";
2016-07-05 21:19:02 +00:00
import 'package:angel_cli/angel_cli.dart';
2017-03-24 20:27:01 +00:00
import 'package:angel_cli/pubspec.dart';
2017-03-24 20:25:50 +00:00
import 'package:console/console.dart';
import 'package:http/http.dart' as http;
2016-07-05 21:19:02 +00:00
2016-09-14 04:33:28 +00:00
final String DOCTOR = "doctor";
2017-03-24 20:25:50 +00:00
main(List<String> args) async {
2016-09-14 04:33:28 +00:00
var runner =
new CommandRunner("angel", "Command-line tools for the Angel framework.");
2016-12-10 18:52:14 +00:00
runner
..addCommand(new DoctorCommand())
2016-12-24 04:42:55 +00:00
..addCommand(new KeyCommand())
2016-12-10 18:52:14 +00:00
..addCommand(new ServiceCommand())
..addCommand(new InitCommand())
..addCommand(new TestCommand())
2016-12-13 17:50:53 +00:00
..addCommand(new PluginCommand())
2017-02-01 22:56:04 +00:00
..addCommand(new StartCommand())
..addCommand(new RenameCommand());
2016-09-14 04:33:28 +00:00
2017-03-24 20:25:50 +00:00
stdout.write('Checking for update... ');
2017-03-25 22:33:28 +00:00
try {
var client = new http.Client();
var update = await checkForUpdate(client);
client.close();
if (update != null) {
stdout.writeln();
var pen = new TextPen();
pen.cyan();
pen.text(
'ATTENTION: There is a new version of the Angel CLI available (version $update).');
pen.text('\nTo update, run `pub global activate angel_cli`.');
pen();
stdout.writeln();
} else
stdout.writeln('No update available.');
} catch (e) {
stdout.writeln('Failed to check for update.');
}
2017-03-24 20:25:50 +00:00
return await runner.run(args).then((_) {}).catchError((exc) {
2016-09-14 04:33:28 +00:00
stderr.writeln("Oops, something went wrong: $exc");
exitCode = 1;
});
}