Add very-verbose flag and automatically log some more process-related things in verbose and very-verbose modes.

This commit is contained in:
Ian Fischer 2015-09-16 10:57:15 -07:00
parent b72d67a8fe
commit d8d87f1833
2 changed files with 12 additions and 0 deletions

View File

@ -32,6 +32,10 @@ void main(List<String> args) {
abbr: 'v',
negatable: false,
help: 'Noisy logging, including all shell commands executed.');
parser.addFlag('very-verbose',
negatable: false,
help: 'Very noisy logging, including the output of all '
'shell commands executed.');
parser.addSeparator('commands:');
for (CommandHandler handler in [
@ -55,6 +59,10 @@ void main(List<String> args) {
Logger.root.level = Level.INFO;
}
if (results['very-verbose']) {
Logger.root.level = Level.FINE;
}
if (results['help']) {
_printUsage(parser, handlers);
} else if (results.command != null) {

View File

@ -13,10 +13,14 @@ String runCheckedSync(List<String> cmd) {
ProcessResult results =
Process.runSync(cmd[0], cmd.getRange(1, cmd.length).toList());
if (results.exitCode != 0) {
if (results.stderr.length > 0) {
_logging.info('Errors logged: ' + results.stderr);
}
throw 'Error code ' +
results.exitCode.toString() +
' returned when attempting to run command: ' +
cmd.join(' ');
}
_logging.fine(results.stdout.trim());
return results.stdout;
}