Created
December 9, 2018 18:17
-
-
Save jaireina/aabcadcc51baf6f7ff904005ffb45e9c to your computer and use it in GitHub Desktop.
Interface for fancy printing your name on the terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)); | |
}); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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