cli-cursor
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
restore-cursor | 3.1.0 | 1.56 kB | MIT | prod |
CLI-Cursor is a handy Node.js package that allows developers to toggle the visibility of the command line interface (CLI) cursor. This is often useful in creating tidy and efficient CLI presentations and user interfaces. Essential to note, CLI-Cursor ensures that the cursor is gracefully restored if the process exits, giving developers one less thing to worry about when coding their CLI applications.
CLI-Cursor is very straightforward to use! To start, install it to your Node.js project using npm with the following command: npm install cli-cursor
. After successfully installing the package, you can import it into your JavaScript file using import cliCursor from 'cli-cursor';
.
To hide the cursor, you just need to call cliCursor.hide();
. On the other hand, if you wish to show the cursor, you can use cliCursor.show();
. If you want to toggle the cursor's visibility based on a certain condition, you can use the toggle method with a boolean argument. For example, you could use cliCursor.toggle(unicornsAreAwesome);
, where unicornsAreAwesome
is a boolean value you've defined in your code.
import cliCursor from 'cli-cursor';
cliCursor.hide(); // hides the cursor
cliCursor.show(); // shows the cursor
const unicornsAreAwesome = true;
cliCursor.toggle(unicornsAreAwesome); // toggles the cursor visibility based on the truthiness of unicornsAreAwesome
Each of these methods accepts an optional stream argument that defaults to process.stderr
.
The CLI-Cursor documentation can be found directly in the README of the CLI-Cursor's GitHub repository, which is available here. The README is quite comprehensive and provides an overview of the package, installation instructions, usage examples, as well as API descriptions. Up-to-date professional subscription support for the package is also available via Tidelift.