Skip to content

Commit 679c4c8

Browse files
authored
fix: add clear line content in task steps (#9)
* fix: close #8 Erase the end of the line after changing cursor position and before printing new text in task component. Refs: #8 * chore: update the README.md update the task example in `README.md` using the example provided in the example directory (`example/task.dart`).
1 parent 4c20fa7 commit 679c4c8

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,19 @@ Future<String> sleepWithValue() =>
106106
107107
Future<void> main() async {
108108
final commander = Commander(level: Level.verbose);
109-
print('Hello World !');
110109
111-
final successTask =
112-
await commander.task('I am an success task', colored: true);
110+
final successTask = await commander.task();
113111
await successTask.step('Success step 1', callback: sleepWithValue);
114112
await successTask.step('Success step 2', callback: sleep);
115113
successTask.success('Success task data are available !');
116114
117-
final warnTask = await commander.task('I am an warn task');
115+
final warnTask = await commander.task();
118116
await warnTask.step('Warn step 1', callback: sleepWithValue);
119117
await warnTask.step('Warn step 2', callback: sleep);
120118
await warnTask.step('Warn step 3', callback: sleep);
121119
warnTask.warn('Warn task !');
122120
123-
final errorTask = await commander.task('I am an error task');
121+
final errorTask = await commander.task();
124122
await errorTask.step('Error step 1', callback: sleepWithValue);
125123
await errorTask.step('Error step 2', callback: sleep);
126124
await errorTask.step('Error step 3', callback: sleep);

lib/src/application/components/task.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ final class StepManager with TerminalTools {
5656

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

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

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

119122
buffer.writeAnsiAll([
120123
CursorPosition.moveTo(_position!.$2 + _lineCount, _position!.$1),
124+
Clear.untilEndOfLine,
121125
..._theme.errorPrefixColor,
122126
Print(_theme.errorPrefix),
123127
SetStyles.reset,

0 commit comments

Comments
 (0)