Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add clear line content in task steps #9

Merged
merged 2 commits into from
Nov 2, 2024
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
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,19 @@ Future<String> sleepWithValue() =>

Future<void> main() async {
final commander = Commander(level: Level.verbose);
print('Hello World !');

final successTask =
await commander.task('I am an success task', colored: true);
final successTask = await commander.task();
await successTask.step('Success step 1', callback: sleepWithValue);
await successTask.step('Success step 2', callback: sleep);
successTask.success('Success task data are available !');

final warnTask = await commander.task('I am an warn task');
final warnTask = await commander.task();
await warnTask.step('Warn step 1', callback: sleepWithValue);
await warnTask.step('Warn step 2', callback: sleep);
await warnTask.step('Warn step 3', callback: sleep);
warnTask.warn('Warn task !');

final errorTask = await commander.task('I am an error task');
final errorTask = await commander.task();
await errorTask.step('Error step 1', callback: sleepWithValue);
await errorTask.step('Error step 2', callback: sleep);
await errorTask.step('Error step 3', callback: sleep);
Expand Down
4 changes: 4 additions & 0 deletions lib/src/application/components/task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ final class StepManager with TerminalTools {

buffer.writeAnsiAll([
CursorPosition.moveToColumn(_position!.$1),
Clear.untilEndOfLine,
..._theme.loadingSymbolColor,
Print(_theme.loadingSymbols[_loadingStep]),
SetStyles.reset
Expand All @@ -78,6 +79,7 @@ final class StepManager with TerminalTools {

buffer.writeAnsiAll([
CursorPosition.moveTo(_position!.$2 + _lineCount, _position!.$1),
Clear.untilEndOfLine,
..._theme.successPrefixColor,
Print(_theme.successPrefix),
SetStyles.reset,
Expand All @@ -98,6 +100,7 @@ final class StepManager with TerminalTools {

buffer.writeAnsiAll([
CursorPosition.moveTo(_position!.$2 + _lineCount, _position!.$1),
Clear.untilEndOfLine,
..._theme.warningPrefixColor,
Print(_theme.warningPrefix),
SetStyles.reset,
Expand All @@ -118,6 +121,7 @@ final class StepManager with TerminalTools {

buffer.writeAnsiAll([
CursorPosition.moveTo(_position!.$2 + _lineCount, _position!.$1),
Clear.untilEndOfLine,
..._theme.errorPrefixColor,
Print(_theme.errorPrefix),
SetStyles.reset,
Expand Down