Yargonaut
:octopus: Decorate yargs content with chalk styles and figlet fonts
Install / Use
/learn @nexdrew/YargonautREADME
yargonaut
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!
Install
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.
Examples
Use a single style and font for all top-level yargs strings:
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
Use one style and font for help content and another for error messages:
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
Customize only specific yargs strings:
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"
Change default rendering strategy for a specific string:
require('yargonaut')
.errors('ANSI Shadow')
.transformWholeString('Unknown argument: %s')
var argv = require('yargs')
.showHelpOnFail(false)
.strict()
.argv
$ node order.js -a -b
██╗ ██╗███╗ ██╗██╗ ██╗███╗ ██╗ ██████╗ ██╗ ██╗███╗ ██╗ █████╗ ██████╗ ██████╗ ██╗ ██╗███╗ ███╗███████╗███╗ ██╗████████╗███████╗ █████╗ ██████╗
██║ ██║████╗ ██║██║ ██╔╝████╗ ██║██╔═══██╗██║ ██║████╗ ██║ ██╔══██╗██╔══██╗██╔════╝ ██║ ██║████╗ ████║██╔════╝████╗ ██║╚══██╔══╝██╔════╝██╗ ██╔══██╗ ██╔══██╗
██║ ██║██╔██╗ ██║█████╔╝ ██╔██╗ ██║██║ ██║██║ █╗ ██║██╔██╗ ██║ ███████║██████╔╝██║ ███╗██║ ██║██╔████╔██║█████╗ ██╔██╗ ██║ ██║ ███████╗╚═╝ ███████║ ██████╔╝
██║ ██║██║╚██╗██║██╔═██╗
