Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
## 0.2.0

- Add `Logger.write` and `Logger.writeCharCode` methods which write without
printing a trailing newline.

## 0.1.4

- Add `Ansi.reversed` getter.

## 0.1.3+2

- Update Dart SDK constraint to < 3.0.0.

## 0.1.3+1

- Update Dart SDK to 2.0.0-dev.

## 0.1.3

- In verbose mode, instead of printing the diff from the last log message,
print the total time since the tool started
- Change to not buffer the last log message sent in verbose logging mode
Expand Down
44 changes: 35 additions & 9 deletions lib/cli_logging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ abstract class Logger {
/// Print trace output.
void trace(String message);

/// Print text to stdout, without a trailing newline.
void write(String message);

/// Print a character code to stdout, without a trailing newline.
void writeCharCode(int charCode);

/// Start an indeterminate progress display.
Progress progress(String message);

Expand Down Expand Up @@ -122,27 +128,39 @@ class StandardLogger implements Logger {
Progress _currentProgress;

void stderr(String message) {
if (_currentProgress != null) {
Progress progress = _currentProgress;
_currentProgress = null;
progress.cancel();
}
_cancelProgress();

io.stderr.writeln(message);
}

void stdout(String message) {
_cancelProgress();

print(message);
}

void trace(String message) {}

void write(String message) {
_cancelProgress();

io.stdout.write(message);
}

void writeCharCode(int charCode) {
_cancelProgress();

io.stdout.writeCharCode(charCode);
}

void _cancelProgress() {
if (_currentProgress != null) {
Progress progress = _currentProgress;
_currentProgress = null;
progress.cancel();
}

print(message);
}

void trace(String message) {}

Progress progress(String message) {
if (_currentProgress != null) {
Progress progress = _currentProgress;
Expand Down Expand Up @@ -260,6 +278,14 @@ class VerboseLogger implements Logger {
io.stdout.writeln('${_createPrefix()}${ansi.gray}$message${ansi.none}');
}

void write(String message) {
io.stdout.write(message);
}

void writeCharCode(int charCode) {
io.stdout.writeCharCode(charCode);
}

Progress progress(String message) => new SimpleProgress(this, message);

@Deprecated('This method will be removed in the future')
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cli_util
version: 0.1.4
version: 0.2.0
author: Dart Team <[email protected]>
description: A library to help in building Dart command-line apps.
homepage: https://github.com/dart-lang/cli_util
Expand Down