Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
The yargonaut npm package is a utility that enhances the yargs command-line argument parser with additional features such as colorization and styling of output. It allows developers to create more visually appealing and user-friendly CLI applications.
Colorization
This feature allows you to colorize the output of your CLI application. In this example, the output will be styled in blue.
const yargonaut = require('yargonaut').style('blue');
const yargs = require('yargs');
console.log(yargonaut.asYargs(yargs).argv);
Styling
This feature allows you to apply different styles to the output, such as making the text bold. In this example, the output will be bold.
const yargonaut = require('yargonaut').style('bold');
const yargs = require('yargs');
console.log(yargonaut.asYargs(yargs).argv);
Custom Themes
This feature allows you to create custom themes for your CLI application. In this example, the main text will be red, and the help text will be green.
const yargonaut = require('yargonaut').style('red').helpStyle('green');
const yargs = require('yargs');
yargs.usage('Usage: $0 <command> [options]')
.command('hello', 'say hello', {}, (argv) => {
console.log('Hello, world!');
})
.help()
.argv;
Chalk is a popular library for styling terminal strings. It provides a wide range of colors and styles, making it a versatile choice for enhancing CLI output. Unlike yargonaut, which is specifically designed to work with yargs, Chalk can be used independently or with any CLI tool.
CLI-Color is another library for styling terminal output. It offers a comprehensive set of features for colorizing and styling text. Similar to Chalk, CLI-Color is not tied to any specific CLI argument parser, giving it broader applicability compared to yargonaut.
Colors is a library that adds color and style to console output. It is simple to use and integrates well with various CLI tools. While it provides similar functionality to yargonaut, it does not have built-in integration with yargs.
Decorate yargs content with chalk styles and figlet fonts
yargonaut is the content decorator for yargs, allowing you to customize your yargs-based CLI output using chalk styles and/or figlet fonts ... easily!
Why? Because CLI apps with color and ASCII Art are more fun!
Could you customize yargs text, possibly using chalk or figlet, without yargonaut? Absolutely. But yargonaut makes it so easy! And yargonaut supports all locales that yargs and figlet support - out of the box.
Could terminal coloring or ASCII Art fonts be annoying in CLI apps? Well, sure. But used tastefully, it can add a degree of creative flair to make your CLI stand out. Use wisely!
npm install --save yargonaut yargs
var yargonaut = require('yargonaut') // yargonaut first!
var yargs = require('yargs') // then yargs
yargonaut assumes you have yargs installed independently.
To automatically support all locales that yargs supports, make sure to require('yargonaut')
in code before you require('yargs')
. This is important! If you choose to ignore this, yargonaut will attempt workarounds as best it can, but any issues caused by incorrect ordering of require()
statements will not be given priority. The ordering should be natural, since you'll need to configure yargonaut before yargs parses CLI args anyway.
Note that yargonaut does not wrap yargs and is not a replacement for yargs. It's built to work with yargs side-by-side, and it doesn't lock you in to a particular version of yargs, though internal string customization is only supported in yargs v3.16.1 and up.
If anything goes wrong, yargonaut attempts to fail gracefully and silently, so your CLI still works, just without the cool colors/fonts.
require('yargonaut')
.style('blue')
.font('Small Slant') // that's it!
var argv = require('yargs')
.command('add', 'Add item to cart')
.command('rm', 'Remove item from cart')
.option('p', {
alias: 'product',
describe: 'Product id(s)',
demand: true
})
.option('s', {
alias: 'size',
describe: 'Desired product size',
choices: ['s', 'm', 'l'],
default: 'm'
})
.option('c', {
alias: 'color',
describe: 'Desired product color'
})
.example('$0 add -p 123 -s l -c green', 'Add large, green product with id 123')
.wrap(null)
.argv
$ node order.js
_____ __ _
/ ___/__ __ _ __ _ ___ ____ ___/ /__ (_)
/ /__/ _ \/ ' \/ ' \/ _ `/ _ \/ _ (_-<_
\___/\___/_/_/_/_/_/_/\_,_/_//_/\_,_/___(_)
add Add item to cart
rm Remove item from cart
____ __ _ _
/ __ \___ / /_(_)__ ___ ___ (_)
/ /_/ / _ \/ __/ / _ \/ _ \(_-<_
\____/ .__/\__/_/\___/_//_/___(_)
/_/
-p, --product Product id(s) [required]
-s, --size Desired product size [choices: "s", "m", "l"] [default: "m"]
-c, --color Desired product color
____ __ _
/ __/_ _____ ___ _ ___ / /__ ___ (_)
/ _/ \ \ / _ `/ ' \/ _ \/ / -_|_-<_
/___//_\_\\_,_/_/_/_/ .__/_/\__/___(_)
/_/
order.js add -p 123 -s l -c green Add large, green product with id 123
__ ____ _ _ __ __ _
/ |/ (_)__ ___ (_)__ ___ _ _______ ___ ___ __(_)______ ___/ / ___ ________ ___ ____ _ ___ ___ / /_(_)
/ /|_/ / (_-<(_-</ / _ \/ _ `/ / __/ -_) _ `/ // / / __/ -_) _ / / _ `/ __/ _ `/ // / ' \/ -_) _ \/ __/
/_/ /_/_/___/___/_/_//_/\_, / /_/ \__/\_, /\_,_/_/_/ \__/\_,_/ \_,_/_/ \_, /\_,_/_/_/_/\__/_//_/\__(_)
/___/ /_/ /___/
p
require('yargonaut')
.help('3D-ASCII')
.helpStyle('green')
.errors('Calvin S')
.errorsStyle('red')
var argv = require('yargs')
.command('add', 'Add item to cart')
.command('rm', 'Remove item from cart')
.option('p', {
alias: 'product',
describe: 'Product id(s)',
demand: true
})
.option('s', {
alias: 'size',
describe: 'Desired product size',
choices: ['s', 'm', 'l'],
default: 'm'
})
.option('c', {
alias: 'color',
describe: 'Desired product color'
})
.example('$0 add -p 123 -s l -c green', 'Add large, green product with id 123')
.wrap(null)
.argv
$ node order.js
________ ________ _____ ______ _____ ______ ________ ________ ________ ________
|\ ____\|\ __ \|\ _ \ _ \|\ _ \ _ \|\ __ \|\ ___ \|\ ___ \|\ ____\ ___
\ \ \___|\ \ \|\ \ \ \\\__\ \ \ \ \\\__\ \ \ \ \|\ \ \ \\ \ \ \ \_|\ \ \ \___|_|\__\
\ \ \ \ \ \\\ \ \ \\|__| \ \ \ \\|__| \ \ \ __ \ \ \\ \ \ \ \ \\ \ \_____ \|__|
\ \ \____\ \ \\\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \\ \ \ \ \_\\ \|____|\ \ ___
\ \_______\ \_______\ \__\ \ \__\ \__\ \ \__\ \__\ \__\ \__\\ \__\ \_______\____\_\ \|\__\
\|_______|\|_______|\|__| \|__|\|__| \|__|\|__|\|__|\|__| \|__|\|_______|\_________\|__|
\|_________|
add Add item to cart
rm Remove item from cart
________ ________ _________ ___ ________ ________ ________
|\ __ \|\ __ \|\___ ___\\ \|\ __ \|\ ___ \|\ ____\ ___
\ \ \|\ \ \ \|\ \|___ \ \_\ \ \ \ \|\ \ \ \\ \ \ \ \___|_|\__\
\ \ \\\ \ \ ____\ \ \ \ \ \ \ \ \\\ \ \ \\ \ \ \_____ \|__|
\ \ \\\ \ \ \___| \ \ \ \ \ \ \ \\\ \ \ \\ \ \|____|\ \ ___
\ \_______\ \__\ \ \__\ \ \__\ \_______\ \__\\ \__\____\_\ \|\__\
\|_______|\|__| \|__| \|__|\|_______|\|__| \|__|\_________\|__|
\|_________|
-p, --product Product id(s) [required]
-s, --size Desired product size [choices: "s", "m", "l"] [default: "m"]
-c, --color Desired product color
_______ ___ ___ ________ _____ ______ ________ ___ _______ ________
|\ ___ \ |\ \ / /|\ __ \|\ _ \ _ \|\ __ \|\ \ |\ ___ \ |\ ____\ ___
\ \ __/| \ \ \/ / | \ \|\ \ \ \\\__\ \ \ \ \|\ \ \ \ \ \ __/|\ \ \___|_|\__\
\ \ \_|/__ \ \ / / \ \ __ \ \ \\|__| \ \ \ ____\ \ \ \ \ \_|/_\ \_____ \|__|
\ \ \_|\ \ / \/ \ \ \ \ \ \ \ \ \ \ \ \___|\ \ \____\ \ \_|\ \|____|\ \ ___
\ \_______\/ /\ \ \ \__\ \__\ \__\ \ \__\ \__\ \ \_______\ \_______\____\_\ \|\__\
\|_______/__/ /\ __\ \|__|\|__|\|__| \|__|\|__| \|_______|\|_______|\_________\|__|
|__|/ \|__| \|_________|
order.js add -p 123 -s l -c green Add large, green product with id 123
╔╦╗┬┌─┐┌─┐┬┌┐┌┌─┐ ┬─┐┌─┐┌─┐ ┬ ┬┬┬─┐┌─┐┌┬┐ ┌─┐┬─┐┌─┐┬ ┬┌┬┐┌─┐┌┐┌┌┬┐
║║║│└─┐└─┐│││││ ┬ ├┬┘├┤ │─┼┐│ ││├┬┘├┤ ││ ├─┤├┬┘│ ┬│ ││││├┤ │││ │
╩ ╩┴└─┘└─┘┴┘└┘└─┘ ┴└─└─┘└─┘└└─┘┴┴└─└─┘─┴┘ ┴ ┴┴└─└─┘└─┘┴ ┴└─┘┘└┘ ┴
p
require('yargonaut')
.font('DOS Rebel', 'Invalid values:')
.style('yellow', 'Invalid values:')
var argv = require('yargs')
.option('s', {
alias: 'size',
describe: 'Desired product size',
choices: ['s', 'm', 'l'],
demand: true
})
.showHelpOnFail(false)
.argv
$ node order.js -s xl
█████ ████ ███ █████ ████
░░███ ░░███ ░░░ ░░███ ░░███
░███ ████████ █████ █████ ██████ ░███ ████ ███████ █████ █████ ██████ ░███ █████ ████ ██████ █████ ██
░███ ░░███░░███ ░░███ ░░███ ░░░░░███ ░███ ░░███ ███░░███ ░░███ ░░███ ░░░░░███ ░███ ░░███ ░███ ███░░███ ███░░ ░░
░███ ░███ ░███ ░███ ░███ ███████ ░███ ░███ ░███ ░███ ░███ ░███ ███████ ░███ ░███ ░███ ░███████ ░░█████
░███ ░███ ░███ ░░███ ███ ███░░███ ░███ ░███ ░███ ░███ ░░███ ███ ███░░███ ░███ ░███ ░███ ░███░░░ ░░░░███
█████ ████ █████ ░░█████ ░░████████ █████ █████░░████████ ░░█████ ░░████████ █████ ░░████████░░██████ ██████ ██
░░░░░ ░░░░ ░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░ ░░
Argument: s, Given: "xl", Choices: "s", "m", "l"
require('yargonaut')
.errors('ANSI Shadow')
.transformWholeString('Unknown argument: %s')
var argv = require('yargs')
.showHelpOnFail(false)
.strict()
.argv
$ node order.js -a -b
██╗ ██╗███╗ ██╗██╗ ██╗███╗ ██╗ ██████╗ ██╗ ██╗███╗ ██╗ █████╗ ██████╗ ██████╗ ██╗ ██╗███╗ ███╗███████╗███╗ ██╗████████╗███████╗ █████╗ ██████╗
██║ ██║████╗ ██║██║ ██╔╝████╗ ██║██╔═══██╗██║ ██║████╗ ██║ ██╔══██╗██╔══██╗██╔════╝ ██║ ██║████╗ ████║██╔════╝████╗ ██║╚══██╔══╝██╔════╝██╗ ██╔══██╗ ██╔══██╗
██║ ██║██╔██╗ ██║█████╔╝ ██╔██╗ ██║██║ ██║██║ █╗ ██║██╔██╗ ██║ ███████║██████╔╝██║ ███╗██║ ██║██╔████╔██║█████╗ ██╔██╗ ██║ ██║ ███████╗╚═╝ ███████║ ██████╔╝
██║ ██║██║╚██╗██║██╔═██╗ ██║╚██╗██║██║ ██║██║███╗██║██║╚██╗██║ ██╔══██║██╔══██╗██║ ██║██║ ██║██║╚██╔╝██║██╔══╝ ██║╚██╗██║ ██║ ╚════██║██╗ ██╔══██║ ██╔══██╗
╚██████╔╝██║ ╚████║██║ ██╗██║ ╚████║╚██████╔╝╚███╔███╔╝██║ ╚████║ ██║ ██║██║ ██║╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ╚████║ ██║ ███████║╚═╝ ██║ ██║▄█╗ ██████╔╝
╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══╝╚══╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝
Render error messages using the specified figlet font.
yargonaut
singletonfont
: string, name of figlet fontApply the given chalk style to error messages, e.g. errorsStyle('red.bold')
.
yargonaut
singletonstyle
: string, the dot-delimited chalk style (color/modifier) to useRender yargs strings using the specified figlet font. Optionally specify which yargs string(s) the font should apply to.
yargonaut
singletonfont
: string, name of figlet fontkey
: string or array of strings, optional key(s) the font should apply toRender help content strings using the specified figlet font.
yargonaut
singletonfont
: string, name of figlet fontApply the given chalk style to help content, e.g. helpStyle('green.underline')
.
yargonaut
singletonstyle
: string, the dot-delimited chalk style (color/modifier) to useFor obsessive control over string transformations, provide a function that yargonaut will call for every yargs string (every y18n lookup).
yargonaut
singletonfn
: function that returns a string and accepts the following:
key
: string, the yargs key being renderedorigString
: string, the original string resolved by y18nnewString
: string, the new string as rendered by yargonaut/figletfiglet
: figlet, the figlet instancefont
: string, the configured figlet font for the keyApply the given chalk style to all yargs strings, e.g. style('blue')
. Optionally specify which yargs string(s) the style should apply to.
yargonaut
singletonstyle
: string, the dot-delimited chalk style (color/modifier) to usekey
: string or array of strings, optional key(s) the style should apply toChange the default splitting/rendering strategy for specific yargs strings.
yargonaut
singletonkey
: string or array of strings, optional key(s) the render strategy should apply toChange the default splitting/rendering strategy for specific yargs strings.
yargonaut
singletonkey
: string or array of strings, optional key(s) the render strategy should apply toGet a list of all known yargs strings (help content + error messages) subject to y18n lookup and yargonaut rendering.
Get a list of known error messages subject to y18n lookup and yargonaut rendering.
Get a list of known help content strings subject to y18n lookup and yargonaut rendering.
Render any text as the given figlet font and return as string.
text
: string, the text to renderfont
: string, the figlet font to use for renderingthrowErr
: boolean, optional flag to throw any error that might occur, defaults to false
Get access to the chalk
instance used by yargonaut. In case you want to color your own strings without having to require('chalk')
yourself.
chalk
, the chalk instanceGet access to the figlet
instance used by yargonaut. I mean, why not?
figlet
, the figlet instanceGet a list of all supported figlet fonts. Maybe you want to mix it up with a random font?
Test print one figlet font to stdout using console.log()
.
font
: string, the figlet font to test printtext
: string, optional text to print as font, defaults to font namethrowErr
: boolean, optional flag to throw any error that might occur, defaults to false
Test print every supported figlet font to stdout using console.log()
.
text
: string, optional text to print as font, defaults to font namethrowErr
: boolean, optional flag to throw any error that might occur, defaults to false
Apache-2.0 © Andrew Goode
FAQs
Decorate yargs content with chalk styles and figlet fonts
The npm package yargonaut receives a total of 129,533 weekly downloads. As such, yargonaut popularity was classified as popular.
We found that yargonaut demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.