Skip to content

Commit

Permalink
changed readme structure
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiDittrich committed Sep 23, 2017
1 parent 34c2949 commit 3a6561f
Showing 1 changed file with 28 additions and 33 deletions.
61 changes: 28 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,11 @@ Features
* Works in Asynchronous and Synchronous tasks
* Preset/Theme support

*Successful tested on Windows10, Debian 8 and Ubuntu 14,15,16*

Progress-Bar
Usage
------------

### Getting Started ###

You can find some basic examples in [example.js](https://github.com/AndiDittrich/Node.CLI-Progress/blob/master/example.js) - just run the file with `$ node example.js`

### Usage ###
Multiple examples are available e.g. [example.js](https://github.com/AndiDittrich/Node.CLI-Progress/blob/master/example.js) - just try it `$ node example.js`

```js
var _progress = require('cli-progress');
Expand All @@ -57,41 +52,55 @@ bar1.update(100);
bar1.stop();
```

### Methods/Syntax ###
Methods/Syntax
-----------------------------------

#### Constructor ####
### Constructor ###

Initialize a new Progress bar. An instance can be used **multiple** times! it's not required to re-create it!

```js
var <instance> = new namespace.Bar(options:object, preset:object);
var <instance> = new namespace.Bar(options:object [, preset:object]);
```

#### start() ####
#### Options ####

- `format` (type:string) - progress bar output format @see format section
- `fps` (type:float) - the maximum update rate (default: 10)
- `stream` (type:stream) - output stream to use (default: `process.stderr`)
- `stopOnComplete` (type:boolean) - automatically call `stop()` when the value reaches the total (default: false)
- `clearOnComplete` (type:boolean) - clear the progress bar on complete / `stop()` call (default: false)
- `barsize` (type:int) - the length of the progress bar in chars (default: 40)
- `barCompleteString` (type:char) - character to use as "complete" indicator in the bar (default: "=")
- `barIncompleteString` (type:char) - character to use as "incomplete" indicator in the bar (default: "-")
- `hideCursor` (type:boolean) - hide the cursor during progress operation; restored on complete (default: false)
- `etaBuffer` (type:int) - number of updates with which to calculate the eta; higher numbers give a more stable eta (default: 10)

### ::start() ###

Starts the progress bar and set the total and initial value

```js
<instance>.start(totalValue:int, startValue:int [, payload:object = {}]);
```

#### update() ####
### ::update() ###

Sets the current progress value and optionally the payload with values of custom tokens as a second parameter

```js
<instance>.update(currentValue:int [, payload:object = {}]);
```

#### increment() ####
### ::increment() ###

Increases the current progress value by a specified amount (default +1)

```js
<instance>.increment(delta:int);
```

#### stop() ####
### ::stop() ###

Stops the progress bar and go to next line

Expand All @@ -100,7 +109,8 @@ Stops the progress bar and go to next line
```


### Bar Formatting ###
Bar Formatting
-----------------------------------

The progressbar can be customized by using the following build-in placeholders. They can be combined in any order.

Expand All @@ -113,7 +123,7 @@ The progressbar can be customized by using the following build-in placeholders.
- `{eta_formatted}` - expected time of accomplishment formatted into appropriate units
- `{duration_formatted}` - elapsed time formatted into appropriate units

#### Example ####
### Example ###

```
progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}
Expand All @@ -125,25 +135,10 @@ is rendered as
progress [========================================] 100% | ETA: 0s | 200/200
```

### Options ###

- `format` (type:string) - progress bar output format @see format section
- `fps` (type:float) - the maximum update rate (default: 10)
- `stream` (type:stream) - output stream to use (default: `process.stderr`)
- `stopOnComplete` (type:boolean) - automatically call `stop()` when the value reaches the total (default: false)
- `clearOnComplete` (type:boolean) - clear the progress bar on complete / `stop()` call (default: false)
- `barsize` (type:int) - the length of the progress bar in chars (default: 40)
- `barCompleteString` (type:char) - character to use as "complete" indicator in the bar (default: "=")
- `barIncompleteString` (type:char) - character to use as "incomplete" indicator in the bar (default: "-")
- `hideCursor` (type:boolean) - hide the cursor during progress operation; restored on complete (default: false)
- `etaBuffer` (type:int) - number of updates with which to calculate the eta; higher numbers give a more stable eta (default: 10)



Examples
---------------------------------------------

#### Example 1 - Set Options ####
### Example 1 - Set Options ###

```js
// change the progress characters
Expand All @@ -158,7 +153,7 @@ var bar = new _progress.Bar({
});
```

#### Example 2 - Change Styles defined by Preset ####
### Example 2 - Change Styles defined by Preset ###

```js
// uee shades preset
Expand Down

0 comments on commit 3a6561f

Please sign in to comment.