cli-ux
cli IO utilities
Last updated a month ago by rasphilco .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cli-ux 
SYNC missed versions from official npm registry.

cli-ux

cli IO utilities

Version CircleCI Appveyor CI Codecov Known Vulnerabilities Downloads/week License

Usage

The following assumes you have installed cli-ux to your project with npm install cli-ux or yarn add cli-ux and have it required in your script (TypeScript example):

import cli from 'cli-ux'
cli.prompt('What is your name?')

JavaScript:

const {cli} = require('cli-ux')

cli.prompt('What is your name?')

cli.prompt()

Prompt for user input.

// just prompt for input
await cli.prompt('What is your name?')

// mask input after enter is pressed
await cli.prompt('What is your two-factor token?', {type: 'mask'})

// mask input on keypress (before enter is pressed)
await cli.prompt('What is your password?', {type: 'hide'})

// yes/no confirmation
await cli.confirm('Continue?')

// "press any key to continue"
await cli.anykey()

prompt demo

cli.url(text, uri)

Create a hyperlink (if supported in the terminal)

await cli.url('sometext', 'https://google.com')
// shows sometext as a hyperlink in supported terminals
// shows https://google.com in unsupported terminals

url demo

cli.open

Open a url in the browser

await cli.open('https://oclif.io')

cli.action

Shows a spinner

// start the spinner
cli.action.start('starting a process')
// show on stdout instead of stderr
cli.action.start('starting a process', {stdout: true})

// stop the spinner
cli.action.stop() // shows 'starting a process... done'
cli.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

cli.annotation

Shows an iterm annotation

// start the spinner
cli.annotation('sometest', 'annotated with this text')

annotation demo

cli.wait

Waits for 1 second or given milliseconds

await cli.wait()
await cli.wait(3000)

cli.tree

Generate a tree and display it

let tree = cli.tree()
tree.insert('foo')
tree.insert('bar')

let subtree = cli.tree()
subtree.insert('qux')
tree.nodes.bar.insert('baz', subtree)

tree.display()

Outputs:

├─ foo
└─ bar
   └─ baz
      └─ qux

Current Tags

  • 4.9.3                                ...           latest (a month ago)
  • 5.0.0-4                                ...           next (15 days ago)

129 Versions

  • 5.0.0-4                                ...           15 days ago
  • 5.0.0-3                                ...           a month ago
  • 5.0.0-2                                ...           a month ago
  • 4.9.3                                ...           a month ago
  • 4.9.2                                ...           a month ago
  • 5.0.0-1                                ...           2 months ago
  • 4.9.1                                ...           2 months ago
  • 4.9.0                                ...           2 months ago
  • 5.0.0-0                                ...           3 months ago
  • 4.8.2                                ...           3 months ago
  • 4.8.1                                ...           4 months ago
  • 4.8.0                                ...           4 months ago
  • 4.7.3                                ...           6 months ago
  • 4.7.2                                ...           6 months ago
  • 4.7.1                                ...           6 months ago
  • 4.7.0                                ...           6 months ago
  • 4.6.3                                ...           6 months ago
  • 4.6.2                                ...           6 months ago
  • 4.6.1                                ...           6 months ago
  • 4.6.0                                ...           6 months ago
  • 4.5.1                                ...           6 months ago
  • 4.5.0                                ...           6 months ago
  • 4.4.1                                ...           6 months ago
  • 4.4.0                                ...           7 months ago
  • 4.3.1                                ...           7 months ago
  • 4.3.0                                ...           7 months ago
  • 4.2.3                                ...           7 months ago
  • 4.2.2                                ...           7 months ago
  • 4.2.1                                ...           7 months ago
  • 4.2.0                                ...           7 months ago
  • 4.1.0                                ...           7 months ago
  • 4.0.1                                ...           7 months ago
  • 4.0.0                                ...           7 months ago
  • 3.5.0                                ...           7 months ago
  • 3.4.1                                ...           8 months ago
  • 3.4.0                                ...           8 months ago
  • 3.3.31                                ...           8 months ago
  • 3.3.30                                ...           8 months ago
  • 3.3.29                                ...           8 months ago
  • 3.3.28                                ...           8 months ago
  • 3.3.27                                ...           8 months ago
  • 3.3.26                                ...           9 months ago
  • 3.3.25                                ...           9 months ago
  • 3.3.24                                ...           9 months ago
  • 3.3.23                                ...           10 months ago
  • 3.3.22                                ...           10 months ago
  • 3.3.21                                ...           10 months ago
  • 3.3.20                                ...           10 months ago
  • 3.3.19                                ...           10 months ago
  • 3.3.18                                ...           10 months ago
  • 3.3.17                                ...           10 months ago
  • 3.3.16                                ...           10 months ago
  • 3.3.15                                ...           10 months ago
  • 3.3.14                                ...           10 months ago
  • 3.3.13                                ...           10 months ago
  • 3.3.12                                ...           10 months ago
  • 3.3.11                                ...           10 months ago
  • 3.3.10                                ...           10 months ago
  • 3.3.9                                ...           10 months ago
  • 3.3.8                                ...           a year ago
  • 3.3.7                                ...           a year ago
  • 3.3.6                                ...           a year ago
  • 3.3.5                                ...           a year ago
  • 3.3.4                                ...           a year ago
  • 3.3.3                                ...           a year ago
  • 3.3.2                                ...           a year ago
  • 3.3.1                                ...           a year ago
  • 3.3.0                                ...           a year ago
  • 3.2.2                                ...           a year ago
  • 3.2.1                                ...           a year ago
  • 3.2.0                                ...           a year ago
  • 3.1.7                                ...           a year ago
  • 3.1.6                                ...           a year ago
  • 3.1.5                                ...           a year ago
  • 3.1.4                                ...           a year ago
  • 3.1.3                                ...           a year ago
  • 3.1.2                                ...           a year ago
  • 3.1.1                                ...           a year ago
  • 3.1.0                                ...           a year ago
  • 3.0.1                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.1.1                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 3.0.0-alpha.5                                ...           a year ago
  • 3.0.0-alpha.4                                ...           a year ago
  • 3.0.0-alpha.3                                ...           a year ago
  • 3.0.0-alpha.2                                ...           a year ago
  • 3.0.0-alpha.1                                ...           a year ago
  • 3.0.0-alpha.0                                ...           a year ago
  • 2.0.21                                ...           a year ago
  • 2.0.20                                ...           a year ago
  • 2.0.19                                ...           a year ago
  • 2.0.18                                ...           a year ago
  • 2.0.17                                ...           a year ago
  • 2.0.16                                ...           a year ago
  • 2.0.15                                ...           a year ago
  • 2.0.14                                ...           a year ago
  • 2.0.13                                ...           a year ago
  • 2.0.12                                ...           a year ago
  • 2.0.11                                ...           a year ago
  • 2.0.10                                ...           a year ago
  • 2.0.9                                ...           a year ago
  • 2.0.8                                ...           a year ago
  • 2.0.7                                ...           a year ago
  • 2.0.6                                ...           a year ago
  • 2.0.5                                ...           a year ago
  • 2.0.4                                ...           a year ago
  • 2.0.3                                ...           a year ago
  • 2.0.2                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.1.13                                ...           a year ago
  • 1.1.12                                ...           a year ago
  • 1.1.11                                ...           a year ago
  • 1.1.10                                ...           a year ago
  • 1.1.9                                ...           a year ago
  • 1.1.8                                ...           a year ago
  • 1.1.7                                ...           a year ago
  • 1.1.6                                ...           a year ago
  • 1.1.5                                ...           a year ago
  • 1.1.4                                ...           a year ago
  • 1.1.3                                ...           a year ago
  • 1.1.2                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.0.1                                ...           a year ago
  • 0.0.0                                ...           a year ago
Downloads
Today 12
This Week 75
This Month 756
Last Day 15
Last Week 642
Last Month 2,116
Dependencies (21)
Dev Dependencies (23)
Dependents (193)

Copyright 2014 - 2016 © taobao.org |