An open API service indexing awesome lists of open source software.

https://github.com/alloc/picotask

CLI tasks with spinners and timers (using picocolors)
https://github.com/alloc/picotask

Last synced: 8 months ago
JSON representation

CLI tasks with spinners and timers (using picocolors)

Awesome Lists containing this project

README

          

# picotask

Bare minimum CLI spinners with labels and elapsed times.

```
pnpm add picotask
```

## Exports

### `Picotask` namespace

```typescript
namespace Picotask {
/**
* Options for Picotask.
*/
interface Options {
/**
* Control whether the elapsed time is visible for this task.
* @default true
*/
elapsed?: boolean
/**
* Control whether the spinner is visible for this task.
*
* The default value is `true` unless `footer: true` is used.
*/
spinner?: boolean
/**
* Always render this task after normal tasks.
*
* This also implies `spinner: false`
*/
footer?: boolean
}
}
```

### `Picotask` class

```typescript
class Picotask {
/**
* Constructor for Picotask.
* @param init - The text or function that returns the text to display for the task.
* @param options - Options to configure the task. If a boolean is provided, it will be used as the `spinner` option.
*/
constructor(
init: string | (() => string),
options: boolean | Picotask.Options = {}
)
/**
* Indicates if the task is a footer task.
*/
readonly isFooter: boolean
/**
* Gets the height of the task in lines.
*/
get height(): number
/**
* Renders the task to the console.
* @param showElapsed - Whether to show the elapsed time. Defaults to `options.elapsed`.
*/
render(showElapsed?: boolean): void
/**
* Updates the task text.
* @param text - The new text to display. If not provided, the `init` constructor argument will be used.
*/
update(text?: string): void
/**
* Finishes the task and (optionally) displays a success message.
* @param text - The text to display on finish. If not provided, nothing is logged.
*/
finish(text?: string): void
}
```