Skip to content
/ picotask Public

CLI tasks with spinners and timers (using picocolors)

License

Notifications You must be signed in to change notification settings

alloc/picotask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

picotask

Bare minimum CLI spinners with labels and elapsed times.

pnpm add picotask

Exports

Picotask namespace

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

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
}

About

CLI tasks with spinners and timers (using picocolors)

Resources

License

Stars

Watchers

Forks

Packages

No packages published