-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
keindev
committed
Nov 25, 2021
1 parent
3a39dec
commit 2ed0d90
Showing
21 changed files
with
164 additions
and
1,499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# ProgressBar | ||
|
||
To add a Progress Bar to your task, use [Task.bar](Task.md#bar) method accepting the string pattern and progress bar parameters. | ||
|
||
```javascript | ||
const progress = new task.bar([template, options]); | ||
``` | ||
|
||
## Constructor | ||
|
||
```typescript | ||
new ProgressBar(template?: string, options?: IProgressBarOptions) | ||
``` | ||
|
||
### IProgressBarOptions: | ||
|
||
| Name | Type | Description | | ||
| :---------------- | :-------- | :---------------------------------------------------------- | | ||
| `badges?` | _boolean_ | Option to add badge | | ||
| `clear?` | _boolean_ | Option to clear the bar on completion | | ||
| `completeChar?` | _string_ | Completion character | | ||
| `current?` | _number_ | Current completed index | | ||
| `gradient?` | _boolean_ | Option to add gradient to pending bar | | ||
| `incompleteChar?` | _string_ | Incomplete character | | ||
| `total?` | _number_ | Total number of ticks to complete | | ||
| `width?` | _number_ | The displayed width of the progress bar defaulting to total | | ||
|
||
### Template (ProgressBar output template) | ||
|
||
| Name | Description | | ||
| :--------- | :----------------------------------- | | ||
| `:bar` | The progress bar itself | | ||
| `:current` | Current tick number | | ||
| `:total` | Total ticks | | ||
| `:elapsed` | Time elapsed in seconds | | ||
| `:percent` | Completion percentage | | ||
| `:eta` | Estimated completion time in seconds | | ||
| `:rate` | Rate of ticks per second | | ||
|
||
> default template: `:bar :rate/bps :percent :eta/s` | ||
## Methods | ||
|
||
### complete | ||
|
||
Completes progress and marks it as successful | ||
|
||
### fail | ||
|
||
Stops the progress and marks it as failed | ||
|
||
### render | ||
|
||
Render output string with [Theme](Theme.md) | ||
|
||
### skip | ||
|
||
Stops the progress and marks it as skipped | ||
|
||
### tick | ||
|
||
Increases current progress on step value | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :-------- | :-------------------------------------------------------------------- | :------------------------------------------------------------------------------ | | ||
| `step?` | _number_ | Value by which the current progress will increase | | ||
| `tokens?` | [_IProgressBarToken_](../interfaces/progressbar.iprogressbartoken.md) | Add custom tokens by adding a `{'name': value}` object parameter to your method | | ||
|
||
#### Example | ||
|
||
```javascript | ||
const bar = new Progress(':bar template with custom :token'); | ||
|
||
bar.tick(10, { token: 100 }); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Theme | ||
|
||
Allows you to set a custom theme options for the tree display. | ||
|
||
## Options | ||
|
||
All theme options is object with several fields: | ||
|
||
```typescript | ||
{ | ||
// status text badge to the task, will be added after the task is completed | ||
badge?: string; | ||
// indication color | ||
color?: string; | ||
// indication symbol | ||
symbol?: string | ||
} | ||
``` | ||
|
||
### Indication types | ||
|
||
| Type | `badge` | `color` | `symbol` | Description | | ||
| :------ | :------: | :---------------------------- | :---------: | :------------------------------------------- | | ||
| default | ✖ | `[default]` - text | `-` | default color | | ||
| active | ✖ | `#4285f4` - symbol | `frame (⠧)` | spinner, progress bar color | | ||
| success | ✖ | `#00c851` - symbol, text, bar | ✔ | task symbol, progress bar color | | ||
| skip | `[skip]` | `#ff8800` - symbol, text, bar | ↓ | task symbol, progress bar color | | ||
| error | `[fail]` | `#ff4444` - symbol, text, bar | ✖ | task symbol, error title, progress bar color | | ||
| message | ✖ | `#2e2e2e` - symbol | ─ | dim pointer to task information | | ||
| info | ✖ | `#33b5e5` - symbol | ℹ | information message symbol | | ||
| warning | ✖ | `#ffbb33` - symbol | ⚠ | warning message symbol | | ||
| subtask | ✖ | `#2e2e2e` - symbol, text | › | dim pointer to subtask | | ||
| list | ✖ | `#4285f4` - symbol | ❯ | list symbol | | ||
| dim | ✖ | `#838584` - symbol, bar | `-` | dim color | | ||
|
||
```javascript | ||
const theme = { | ||
default: '#ffffff', | ||
success: ['#008000', '✔'], | ||
skip: { | ||
symbol: '↓', | ||
}, | ||
error: ['#ff0000', '✖', '[error]'], | ||
... | ||
}; | ||
``` |
Oops, something went wrong.