Skip to content

Instantly share code, notes, and snippets.

@jaireina
Created December 9, 2018 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaireina/aabcadcc51baf6f7ff904005ffb45e9c to your computer and use it in GitHub Desktop.
Save jaireina/aabcadcc51baf6f7ff904005ffb45e9c to your computer and use it in GitHub Desktop.
Interface for fancy printing your name on the terminal
#!/usr/bin/env node
const figlet = require('figlet');
const inquirer = require('inquirer');
const colors = require('colors/safe');
const COLORS = [
'black',
'red',
'green',
'yellow',
'blue',
'magenta',
'cyan',
'white'
];
inquirer
.prompt([
{
type: 'input',
name: 'name',
message: "What's your name"
},
{
type: 'list',
name: 'color',
message: 'Choose a text color',
choices: COLORS,
default: 'white'
},
{
type: 'list',
name: 'bgColor',
message: 'Choose a background color',
choices: COLORS,
default: 'black'
}
]).then(({name, color, bgColor})=>{
name = name.trim()==='' ? "C3PO":name;
bgColor = `bg${bgColor.charAt(0).toUpperCase() + bgColor.slice(1)}`;
figlet(name, function(err, data) {
if (err) {
console.log('Something went wrong...');
console.dir(err);
return;
}
console.log(colors[color][bgColor](data));
});
})
{
"name": "print-your-name",
"version": "1.0.0",
"description": "Fancy print your name on the terminal with colors",
"main": "index.js",
"scripts": {},
"repository": {
"type": "gist"
},
"bin": {
"presentation": "./index.js"
},
"keywords": [
"name",
"print",
"terminal"
],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/jaireina/presentation/issues"
},
"homepage": "https://github.com/jaireina/presentation#readme",
"dependencies": {
"colors": "^1.3.2",
"figlet": "^1.2.1",
"inquirer": "^6.2.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment