A collection of wheels I don't want to reinvent over and over again anymore.
npm install @das.laboratory/cli-helpers
Start with instantiating the helpers and provide a width. Then use the included helpers.
import CliHelpers from '@das.laboratory/cli-helpers';
const cliWidth = 100;
const cliHelpers = new CliHelpers(cliWidth);
cliHelpers.showMessage("Let's put a pin in that pre launch throughput!", 76);
Or import individual helpers without configuring the default width:
import { clearScreen, showMessage } from '@das.laboratory/cli-helpers';
clearScreen();
showMessage("Let's put a pin in that pre launch throughput!", 76, 100);
Checkout the examples file for more... uhm... examples.
Outputs a header, centered inside a red box with rounded corners.
console.log(cliHelpers.header("I'm the header! I'm " + cliWidth + ' chars wide (80 by default)!'));
Type: string
The text to be shown.
Type: number
Default: 80
The length of the header.
Displays the ILY version of the simpleshow logo (aka the interactive logo), centered using a given line length.
console.log(cliHelpers.showLogo(100));
Type: number
Default: 80
The length of a line. Used to center the logo.
Outputs the input text, centered and wrapped over multiple lines if too long.
console.log(
cliHelpers.centerText(
"Our competitors are jumping the shark, can you send me an invite?. Land the plane if you want to motivate these clowns. Try less carrot and more stick by moving the needle for high-performance keywords or game plans. Closing these latest prospects is like putting socks on an octopus. Identify pain points, and let's not solutionize this right now. Just parking-lot this for on-brand but wholly fresh ideas and overcome key issues to meet critical milestones. Circle back so ladder up / ladder back to the strategy.",
76,
100
)
);
Type: string
The text to be shown.
Type: number
Default: 76
The maximum length of text per line.
Type: number
Default: 80
The maximum length of the line, including text and whitespace.
This is the more opinionated shorthand version of centerText()
. It adds one linebreak before and two after the text. It also console.logs the text directly, instead of just returning the string.
cliHelpers.showMessage("Let's put a pin in that pre launch throughput!", 76, 100);
Type: string
The text to be shown.
Type: number
Default: 76
The maximum length of text per line.
Type: number
Default: 80
The maximum length of the line, including text and whitespace.
Outputs a message and waits for the user to press a key to continue. Asynchronous.
await cliHelpers.keyToContinue('Press any key to continue...', 100);
Type: string
The text to be shown.
Type: number
Default: 80
The maximum length of the line, including text and whitespace.
Clears the terminal in the same no-history and no-scroll-back way that using cmd + k does.
cliHelpers.clearScreen();
Clears the terminal in the same way that the 'clear' command does (not erasing the history).
cliHelpers.softClear();
This library uses Parcel 2 for bundling. Use these npm scripts to get started.
npm start
# or
npm run watch
# or
npm run dev
# or
npx parcel watch
npm run build
# or
npx parcel build
npm run bump:<newversion> --message=<commitmessage>
newversion: major | minor | patch | premajor | preminor | prepatch | prerelease
commitmessage: A string that will become the commit message (if unclean, the repository will be committed before published on npm)
npm run bump:patch --message="Fixed that thing with the error. Like... you know. That error."
If you don't want npm to make any changes and that it should only report what it would have done, use the --dry-run
flag:
npm publish --dry-run
See also: npm-version npm-publish Updating your published package version number