Skip to content

Commit

Permalink
fix(progress): add debug option which sets out verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
snickbit committed Aug 9, 2023
1 parent cdb6bba commit fca2155
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 3 deletions.
39 changes: 39 additions & 0 deletions packages/progress/docs/classes/MultiProgress.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ https://github.com/npkgz/cli-progress
- [options](MultiProgress.md#options)
- [out](MultiProgress.md#out)

### Accessors

- [isDebug](MultiProgress.md#isdebug)

### Methods

- [create](MultiProgress.md#create)
- [debug](MultiProgress.md#debug)
- [eta](MultiProgress.md#eta)
- [fail](MultiProgress.md#fail)
- [finish](MultiProgress.md#finish)
Expand Down Expand Up @@ -107,6 +112,20 @@ ___

[Progress](Progress.md).[out](Progress.md#out)

## Accessors

### isDebug

`get` **isDebug**(): `boolean`

#### Returns

`boolean`

#### Inherited from

Progress.isDebug

## Methods

### create
Expand All @@ -127,6 +146,26 @@ Create a child progress bar

___

### debug

**debug**(`value?`): [`MultiProgress`](MultiProgress.md)

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `value` | `boolean` | `true` |

#### Returns

[`MultiProgress`](MultiProgress.md)

#### Inherited from

[Progress](Progress.md).[debug](Progress.md#debug)

___

### eta

**eta**(): `string` \| `number`
Expand Down
39 changes: 39 additions & 0 deletions packages/progress/docs/classes/MultiProgressChild.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ Multi-progress child bar
- [options](MultiProgressChild.md#options)
- [out](MultiProgressChild.md#out)

### Accessors

- [isDebug](MultiProgressChild.md#isdebug)

### Methods

- [debug](MultiProgressChild.md#debug)
- [eta](MultiProgressChild.md#eta)
- [fail](MultiProgressChild.md#fail)
- [finish](MultiProgressChild.md#finish)
Expand Down Expand Up @@ -67,8 +72,42 @@ ___

[Progress](Progress.md).[out](Progress.md#out)

## Accessors

### isDebug

`get` **isDebug**(): `boolean`

#### Returns

`boolean`

#### Inherited from

Progress.isDebug

## Methods

### debug

**debug**(`value?`): [`MultiProgressChild`](MultiProgressChild.md)

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `value` | `boolean` | `true` |

#### Returns

[`MultiProgressChild`](MultiProgressChild.md)

#### Inherited from

[Progress](Progress.md).[debug](Progress.md#debug)

___

### eta

**eta**(): `string` \| `number`
Expand Down
31 changes: 31 additions & 0 deletions packages/progress/docs/classes/Progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ https://github.com/npkgz/cli-progress
- [options](Progress.md#options)
- [out](Progress.md#out)

### Accessors

- [isDebug](Progress.md#isdebug)

### Methods

- [debug](Progress.md#debug)
- [eta](Progress.md#eta)
- [fail](Progress.md#fail)
- [finish](Progress.md#finish)
Expand Down Expand Up @@ -69,8 +74,34 @@ ___

**out**: `Out`

## Accessors

### isDebug

`get` **isDebug**(): `boolean`

#### Returns

`boolean`

## Methods

### debug

**debug**(`value?`): [`Progress`](Progress.md)

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `value` | `boolean` | `true` |

#### Returns

[`Progress`](Progress.md)

___

### eta

**eta**(): `string` \| `number`
Expand Down
11 changes: 11 additions & 0 deletions packages/progress/docs/interfaces/MultiProgressChildConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [autoStart](MultiProgressChildConfig.md#autostart)
- [config](MultiProgressChildConfig.md#config)
- [current](MultiProgressChildConfig.md#current)
- [debug](MultiProgressChildConfig.md#debug)
- [id](MultiProgressChildConfig.md#id)
- [message](MultiProgressChildConfig.md#message)
- [name](MultiProgressChildConfig.md#name)
Expand Down Expand Up @@ -53,6 +54,16 @@ ___

___

### debug

`Optional` **debug**: `boolean`

#### Inherited from

[ProgressConfig](ProgressConfig.md).[debug](ProgressConfig.md#debug)

___

### id

**id**: `string`
Expand Down
7 changes: 7 additions & 0 deletions packages/progress/docs/interfaces/ProgressConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [autoStart](ProgressConfig.md#autostart)
- [config](ProgressConfig.md#config)
- [current](ProgressConfig.md#current)
- [debug](ProgressConfig.md#debug)
- [message](ProgressConfig.md#message)
- [name](ProgressConfig.md#name)
- [out](ProgressConfig.md#out)
Expand All @@ -39,6 +40,12 @@ ___

___

### debug

`Optional` **debug**: `boolean`

___

### message

**message**: `string`
Expand Down
2 changes: 1 addition & 1 deletion packages/progress/src/MultiProgress.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class MultiProgress extends Progress {
}

protected setup(): this {
if (!this.out.isVerbose() && this.id) {
if (!this.isDebug && this.id) {
this.multibar = new cliProgress.MultiBar(makeProgressConfig(this.options), cliProgress.Presets.shades_classic)
}
return this
Expand Down
2 changes: 1 addition & 1 deletion packages/progress/src/MultiProgressChild.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class MultiProgressChild extends Progress {
* @internal
*/
protected setup() {
if (!this.out.isVerbose()) {
if (!this.isDebug) {
this.bar = this.options.parent.multibar.create()
}
return this
Expand Down
13 changes: 12 additions & 1 deletion packages/progress/src/Progress.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ProgressConfig {
total: number
current: number
out?: Out
debug?: boolean
config: Partial<CLIProgressOptions>
}

Expand Down Expand Up @@ -47,6 +48,12 @@ export class Progress {
}
}

debug(value = true) {
this.options.debug = value
this.out.setVerbosity(value ? 4 : 1)
return this
}

/**
* Get the ETA
*/
Expand Down Expand Up @@ -186,8 +193,12 @@ export class Progress {
return this
}

get isDebug() {
return this.options.debug || this.out.isVerbose()
}

protected setup(): this {
if (!this.out.isVerbose()) {
if (!this.isDebug) {
this.bar = new cliProgress.SingleBar(makeProgressConfig(this.options), cliProgress.Presets.shades_classic)
}
return this
Expand Down

0 comments on commit fca2155

Please sign in to comment.