oclif: The Open CLI Framework
  • Getting Started
  • API Reference
  • Blog
  • GitHub

›How to

Getting Started

  • Introduction
  • Features
  • FAQs
  • Generator Commands

Architecture

  • Command Execution
  • Plugin Loading

API Reference

  • Commands
  • Command Arguments
  • Command Flags
  • Configuration
  • Topics
  • Topic Separators
  • Hooks
  • Plugins
  • Help Classes
  • Error Handling
  • JSON

How to

  • Release
  • Testing
  • Running Commands Programmatically
  • Aliases
  • Custom Base Class
  • Prompting
  • Spinner
  • Table
  • Notifications
  • Debugging
  • Flexible Taxonomy
  • Global Flags
  • Single Command CLI
  • ESM

Also See

  • Examples
  • External Links
  • Related Repositories
  • How We Work
  • Feedback
Edit

Spinner

@oclif/core provides a simple ux.action, for more complex progress indicators we recommend using the listr library.

ux.action

Shows a basic spinner

import {Command, ux} from '@oclif/core'

export class MyCommand extends Command {
  async run() {
    // start the spinner
    ux.action.start('starting a process')
    // do some action...
    // stop the spinner
    ux.action.stop() // shows 'starting a process... done'

    // show on stdout instead of stderr
    ux.action.start('starting a process', 'initializing', {stdout: true})
    // do some action...
    // stop the spinner with a custom message
    ux.action.stop('custom message') // shows 'starting a process... custom message'
  }
}

This degrades gracefully when not connected to a TTY. It queues up any writes to stdout/stderr so they are displayed above the spinner.

action demo

listr

Here is an example of the complex workflows supported by listr.

listr demo

Last updated on 2/22/2023
← PromptingTable →
Made with 💜 by Salesforce — MIT License