Cli steps ⛹
This module makes it super simple to show animated steps on the terminal and also track the time spent to perform those steps.
Highly inspired by yarn
Some bragging 🤘🏻
Below is the output of couple of examples of what you can do with cli-step
.
output
Yarn stylenpm
Publish toUsage ✍️
Grab it from npm.
npm i cli-step # yarn yarn add cli-step
const Steps = const totalNumberOfSteps = 4const steps = totalNumberOfSteps const step1 = steps start // perform your taskstep1 const step2 = steps start // peform next taskstep2
Note 🗒️
Cli steps doesn't gives you any functionality on how to perform certain actions, it's just a module to show animated steps of the tasks you are executing.
So think of it as the UI layer for your command line app.
Why? 🤷♂️
- To produce consistent output
- Everyone loves emoji's
- Record time taken to perform all the steps.
API 👇🏻
Here's the list of methods you can call to tweak the output.
advance(text, emoji, helpLabel)
- text ( String ) [required] The text to be printed on the terminal. It is required
- emoji (String) [optional] Emoji to be printed just before the text. The emoji name must one of the available emojis from this list
- helpLabel (String) [optional] The help label to be printed in DIM color. For example showing the command used to execute the task
const steps = 4const stepInstance = steps
startRecording
Optionally, you can start recording the time which can later be used to know the time taken to execute all the tasks. Used in yarn example
const steps = 4steps // perform all tasks const nanoSeconds = steps
stopRecording
Used to stop recording the time. The return value is the time spent between startRecording
and stopRecording
in nano seconds.
A single step ☝️
Everytime you call advance
it returns an instance of the step class, which can be used to tweak the output, complete a step and so on.
const step1 = steps step1start // start the animation try // perform task step1 catch error step1
start
The start method starts the animation for a given step.
stepstart
success(text, emoji)
- text ( String ) [optional] Optionally change the text on step completion
- emoji (String) [optional] Optionally change the emoji on step completion
step1complete // or change textstep1complete'Success' // or change text and emojistep1complete'Success' 'white_check_mark'
error(text, emoji)
- text ( String ) [optional] Optionally change the text on error
- emoji (String) [optional] Optionally change the emoji on error
step1 // or change textstep1 // or change text and emojistep1
stop()
Same as error
and complete
but instead doesn't accept any params and just stops the animation.
update(text)
- text ( String ) [required] Update the step text during animation.
step1start // after a whilestep1
Spinner 🤸♂️
The cli-spinner module is used to show the loading icon. You can tweak the behaviour by accessing the spinner
property on the step
instance.
const Steps = const steps = 1 const step = steps // update the spinner stringstepspinner // start animationstepstart
Props 🎉
The module is possible because of