Skip to content

Commit 94d43f4

Browse files
committed
stdout/stderr fixes
1 parent ba7ca76 commit 94d43f4

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

bin/dartdoc.dart

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ main(List<String> arguments) async {
2525
try {
2626
args = parser.parse(arguments);
2727
} on FormatException catch (e) {
28-
print(e.message);
29-
print('');
28+
stderr.writeln(e.message);
29+
stderr.writeln('');
3030
// http://linux.die.net/include/sysexits.h
3131
// #define EX_USAGE 64 /* command line usage error */
3232
_printUsageAndExit(parser, exitCode: 64);
3333
}
3434

3535
if (args['help']) {
36-
_printHelp(parser);
36+
_printHelpAndExit(parser);
3737
}
3838

3939
if (args['version']) {
@@ -135,7 +135,7 @@ main(List<String> arguments) async {
135135
if (record.level == progressLevel) {
136136
if (showProgress && stopwatch.elapsed.inMilliseconds > 250) {
137137
writingProgress = true;
138-
stderr.write('.');
138+
stdout.write('.');
139139
stopwatch.reset();
140140
}
141141
return;
@@ -151,13 +151,17 @@ main(List<String> arguments) async {
151151
assert(message == message.trimRight());
152152
assert(message.isNotEmpty);
153153

154-
if (message.endsWith('...')) {
155-
// Assume there may be more progress to print, so omit the trailing
156-
// newline
157-
writingProgress = true;
158-
stdout.write(message);
154+
if (record.level < logging.Level.WARNING) {
155+
if (message.endsWith('...')) {
156+
// Assume there may be more progress to print, so omit the trailing
157+
// newline
158+
writingProgress = true;
159+
stdout.write(message);
160+
} else {
161+
print(message);
162+
}
159163
} else {
160-
print(message);
164+
stderr.writeln(message);
161165
}
162166
});
163167

@@ -359,7 +363,7 @@ ArgParser _createArgsParser() {
359363
}
360364

361365
/// Print help if we are passed the help option.
362-
void _printHelp(ArgParser parser, {int exitCode: 0}) {
366+
void _printHelpAndExit(ArgParser parser, {int exitCode: 0}) {
363367
print('Generate HTML documentation for Dart libraries.\n');
364368
_printUsageAndExit(parser, exitCode: exitCode);
365369
}

0 commit comments

Comments
 (0)