CliProgress class final
An operation going on, shown until it ends in one line saying how it went: Cli.progress starts one.
What it shows follows what the output can do, fixed when it starts:
- In the interactive mode (a terminal that redraws, somebody at it): a
spinner, the message and the time so far, live in the inline session
below what is live there already, and below the prompts asked while
it runs; lines logged meanwhile land above it. The terminal's tab
shows a progress going on (OSC 9;4, where the terminal takes it).
The closing line, committed in its place, carries the time it took:
✓ Built in 3.1 s. - On a terminal that does not redraw (
NO_COLOR,TERM=dumb,--no-color, and where nobody answers,CIor--no-input): the message as it starts, each changed message from update, and the closing line,✓ Built. - Where the output is no terminal (a pipe, a file, a CI log): the closing line alone, so the record holds the outcome and no frames.
The closing line is written once, by whichever of complete, fail and cancel comes first (cancel writes none); every later call is ignored, and so is update. run closes it on its body's outcome, so an error cannot leave a spinner, and the frames it asks for, going. Its lines are written whatever the console's level, as a prompt's are.
final count = await cli
.progress('Writing files')
.run(writeFiles, done: (n) => 'Wrote $n files');
Properties
- elapsed → Duration
-
How long it has gone on, or went on until it was closed.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isActive → bool
-
Whether it is still going: none of complete, fail and cancel
has been called.
no setter
- message → String
-
What it says it is doing.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancel(
) → void - Ends it without a closing line: what was live goes.
-
complete(
[String? message]) → void -
Ends it done, its closing line
✓andmessage, else the last one. -
fail(
[String? message]) → void -
Ends it failed, its closing line
✗andmessage, else the last one. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run<
T> (FutureOr< T> body(), {String done(T result)?, String failed(Object error)?, bool ok(T result)?}) → Future<T> -
Runs
bodyunder it and closes it on the outcome: complete withdone's message for the value, fail withfailed's for the error, which is thrown again. Completes with the body's value. A value that is a failure (a result of an error, an exit code) closes it with fail whereoksays it is not ok,done's message the line's. -
toString(
) → String -
A string representation of this object.
inherited
-
update(
String message) → void -
Says
messagewhile the operation goes on: shown in place of the last one where it is live, written as a line on a terminal that does not redraw where it is not the one written last, kept for the closing line where the output is no terminal.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited