Remove problematic Map casts

This commit is contained in:
Tobe O 2018-07-14 19:06:48 -04:00
parent 96b9668ad5
commit dca32896eb
2 changed files with 11 additions and 4 deletions

View file

@ -11,6 +11,9 @@ main(List<String> args) async {
var runner = var runner =
new CommandRunner("angel", "Command-line tools for the Angel framework."); new CommandRunner("angel", "Command-line tools for the Angel framework.");
runner.argParser
.addFlag('verbose', help: 'Print verbose output', negatable: false);
runner runner
..addCommand(new DoctorCommand()) ..addCommand(new DoctorCommand())
..addCommand(new KeyCommand()) ..addCommand(new KeyCommand())
@ -19,12 +22,16 @@ main(List<String> args) async {
..addCommand(new RenameCommand()) ..addCommand(new RenameCommand())
..addCommand(new MakeCommand()); ..addCommand(new MakeCommand());
return await runner.run(args).then((_) {}).catchError((exc) { return await runner.run(args).then((_) {}).catchError((exc, st) {
if (exc is String) { if (exc is String) {
stdout.writeln(exc); stdout.writeln(exc);
} else { } else {
stderr.writeln("Oops, something went wrong: $exc"); stderr.writeln("Oops, something went wrong: $exc");
exitCode = 1; exitCode = 1;
if (args.contains('--verbose')) {
stderr.writeln(st);
}
} }
}); });
} }

View file

@ -73,7 +73,7 @@ class InstallCommand extends Command {
throw 'No add-on named "$packageName" is installed. You might need to run `angel install --update`.'; throw 'No add-on named "$packageName" is installed. You might need to run `angel install --update`.';
print('Installing $packageName...'); print('Installing $packageName...');
Map<String, dynamic> values = { Map values = {
'project_name': pubspec.name, 'project_name': pubspec.name,
'pubspec': pubspec, 'pubspec': pubspec,
}; };
@ -106,7 +106,7 @@ class InstallCommand extends Command {
if (await promptFile.exists()) { if (await promptFile.exists()) {
var contents = await promptFile.readAsString(); var contents = await promptFile.readAsString();
var y = yaml.loadYamlDocument(contents); var y = yaml.loadYamlDocument(contents);
var cfg = y.contents.value as Map<String, dynamic>; var cfg = y.contents.value as Map;
// Loads globs // Loads globs
if (cfg['templates'] is List) { if (cfg['templates'] is List) {
@ -115,7 +115,7 @@ class InstallCommand extends Command {
} }
if (cfg['values'] is Map) { if (cfg['values'] is Map) {
var val = cfg['values'] as Map<String, dynamic>; var val = cfg['values'] as Map;
for (var key in val.keys) { for (var key in val.keys) {
var desc = val[key]['description'] ?? key; var desc = val[key]['description'] ?? key;