Comparing version 1.1.3 to 1.2.0
@@ -38,3 +38,3 @@ #!/usr/bin/env node | ||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
Program.usage('"<value>" [option1] <input1> [option2] <input1>,<input2> [option3]\n' + (' Example: $ ' + Chalk.bold('cfonts "sexy font" -f chrome -a center -c red,green,gray'))).description('This is a tool for sexy fonts in the console. Give your cli some love.').version('v' + Version).option('-f, --font <keyword>', 'define "font face"', 'block').option('-a, --align <keyword>', 'define "alignment" for the text', 'left').option('-c, --colors <keyword>,<keyword>...', 'provide colors for text; comma separated (no space)', 'white').option('-b, --background <keyword>', 'provide background color', 'Black').option('-l, --letter-spacing <n>', 'define letter spacing {integer}').option('-z, --line-height <n>', 'define line height {integer}', 1).option('-s, --spaceless', 'surpress space on top and on the bottom').option('-m, --max-length <keyword>', 'define how many character can be on one line').action(function (text) { | ||
Program.usage('"<value>" [option1] <input1> [option2] <input1>,<input2> [option3]\n' + (' Example: $ ' + Chalk.bold('cfonts "sexy font" -f chrome -a center -c red,green,gray'))).description('This is a tool for sexy fonts in the console. Give your cli some love.').version('v' + Version).option('-f, --font <keyword>', 'define "font face"', 'block').option('-a, --align <keyword>', 'define "alignment" for the text', 'left').option('-c, --colors <keyword>,<keyword>...', 'provide colors for text; comma separated (no space)', 'system').option('-b, --background <keyword>', 'provide background color', 'transparent').option('-l, --letter-spacing <n>', 'define letter spacing {integer}').option('-z, --line-height <n>', 'define line height {integer}', 1).option('-s, --spaceless', 'surpress space on top and on the bottom').option('-m, --max-length <keyword>', 'define how many character can be on one line').action(function (text) { | ||
Program.text = text; //add flagless option for text | ||
@@ -41,0 +41,0 @@ }).on('--help', function () { |
40
index.js
@@ -19,2 +19,6 @@ /*************************************************************************************************************************************************************** | ||
var _assign = require('babel-runtime/core-js/object/assign'); | ||
var _assign2 = _interopRequireDefault(_assign); | ||
var _repeat = require('babel-runtime/core-js/string/repeat'); | ||
@@ -28,2 +32,3 @@ | ||
var WinSize = require('window-size'); | ||
var Style = require('ansi-styles'); | ||
var Chalk = require('chalk'); | ||
@@ -182,2 +187,10 @@ var Fs = require('fs'); | ||
// Private function | ||
// AnsiSytle, return all ansi codes with open and close keys | ||
// | ||
// @return {object} An object with all supported ansi escape sequences | ||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
var AnsiSytle = (0, _assign2.default)({ system: { open: '', close: '' } }, Style); | ||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
// Private function | ||
// Colorize, replace placeholders with color information | ||
@@ -192,3 +205,3 @@ // | ||
var candyColors = ['red', 'green', 'yellow', 'magenta', 'cyan']; //allowed candy colors | ||
var candyColors = ['red', 'green', 'yellow', 'magenta', 'cyan', 'redBright', 'greenBright', 'yellowBright', 'blueBright', 'magentaBright', 'cyanBright']; //allowed candy colors | ||
@@ -202,3 +215,3 @@ if (character !== undefined) { | ||
var color = CFonts.OPTIONS.colors[i] || 'white'; | ||
var color = CFonts.OPTIONS.colors[i] || 'system'; | ||
@@ -209,4 +222,4 @@ if (color === 'candy') { | ||
character = character.replace(open, Chalk.styles[color.toLowerCase()].open); | ||
character = character.replace(close, Chalk.styles[color.toLowerCase()].close); | ||
character = character.replace(open, AnsiSytle[color].open); | ||
character = character.replace(close, AnsiSytle[color].close); | ||
} | ||
@@ -216,3 +229,3 @@ } | ||
if (CFonts.FONTFACE.colors === 1) { | ||
var _color = CFonts.OPTIONS.colors[0] || 'white'; | ||
var _color = CFonts.OPTIONS.colors[0] || 'system'; | ||
@@ -223,3 +236,3 @@ if (_color === 'candy') { | ||
character = Chalk.styles[_color.toLowerCase()].open + character + Chalk.styles[_color.toLowerCase()].close; | ||
character = AnsiSytle[_color].open + character + AnsiSytle[_color].close; | ||
} | ||
@@ -281,5 +294,5 @@ } | ||
COLORS: [//All allowed font colors | ||
'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'gray'], | ||
'system', 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'gray', 'redBright', 'greenBright', 'yellowBright', 'blueBright', 'magentaBright', 'cyanBright', 'whiteBright'], | ||
BGCOLORS: [//All allowed background colors | ||
'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'], | ||
'transparent', 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'blackBright', 'redBright', 'greenBright', 'yellowBright', 'blueBright', 'magentaBright', 'cyanBright', 'whiteBright'], | ||
ALIGNMENT: [//All allowed alignment options | ||
@@ -325,3 +338,3 @@ 'left', 'center', 'right'], | ||
colors: SETTINGS.colors || [], | ||
background: ChangeCase.upperCaseFirst(SETTINGS.background) || 'Black', | ||
background: SETTINGS.background || SETTINGS.backgroundColor || 'transparent', | ||
letterSpacing: SETTINGS.letterSpacing === undefined ? 1 : SETTINGS.letterSpacing, | ||
@@ -358,3 +371,3 @@ lineHeight: SETTINGS.lineHeight === undefined ? 1 : parseInt(SETTINGS.lineHeight), | ||
//CHECKING BACKGROUND COLORS | ||
if (CFonts.BGCOLORS.indexOf(CFonts.OPTIONS.background.toLowerCase()) === -1) { | ||
if (CFonts.BGCOLORS.indexOf(CFonts.OPTIONS.background) === -1) { | ||
CFonts.log.error('"' + Chalk.red(CFonts.OPTIONS.background) + '" is not a valid background option.\n' + ('Please use a color from the supported stack:\n' + Chalk.green('[ ' + CFonts.BGCOLORS.join(' | ') + ' ]'))); | ||
@@ -506,8 +519,9 @@ | ||
write = '\n\n' + write + '\n\n'; | ||
} else { | ||
write = '\n' + write; | ||
} | ||
write = Chalk['bg' + CFonts.OPTIONS.background](write); //result in one string | ||
if (CFonts.OPTIONS.background !== 'transparent') { | ||
var bgcolor = 'bg' + ChangeCase.upperCaseFirst(CFonts.OPTIONS.background); | ||
write = AnsiSytle[bgcolor].open + '\n' + write + AnsiSytle[bgcolor].close; //result in one string with background | ||
} | ||
@@ -514,0 +528,0 @@ return { |
{ | ||
"name": "cfonts", | ||
"description": "Sexy fonts for the console", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -36,3 +36,3 @@ "author": { | ||
"build": "npm run build:bin & npm run build:lib", | ||
"build:bin": "babel src/bin.js --out-file bin/font.js --presets=es2015 --plugins transform-runtime", | ||
"build:bin": "mkdir bin && babel src/bin.js --out-file bin/font.js --presets=es2015 --plugins transform-runtime", | ||
"build:lib": "babel src/lib.js --out-file index.js --presets=es2015 --plugins transform-runtime", | ||
@@ -47,3 +47,3 @@ "watch": "npm run build && onchange 'src/**/*' -- npm run build" | ||
"grunt-contrib-jshint": "^1.0.0", | ||
"grunt-exec": "^1.0.0", | ||
"grunt-exec": "^3.0.0", | ||
"onchange": "^3.2.1" | ||
@@ -53,7 +53,8 @@ }, | ||
"dependencies": { | ||
"babel-runtime": "6.22.0", | ||
"chalk": "1.0.0", | ||
"change-case": "3.0.0", | ||
"commander": "2.9.0", | ||
"window-size": "0.3.0" | ||
"ansi-styles": "^3.2.1", | ||
"babel-runtime": "^6.26.0", | ||
"chalk": "^2.3.2", | ||
"change-case": "^3.0.2", | ||
"commander": "^2.15.1", | ||
"window-size": "^1.1.0" | ||
}, | ||
@@ -60,0 +61,0 @@ "keywords": [ |
@@ -48,10 +48,10 @@ ```shell | ||
CFonts.say('Hello|world!', { | ||
font: 'block', //define the font face | ||
align: 'left', //define text alignment | ||
colors: ['white'], //define all colors | ||
background: 'Black', //define the background color | ||
letterSpacing: 1, //define letter spacing | ||
lineHeight: 1, //define the line height | ||
space: true, //define if the output text should have empty lines on top and on the bottom | ||
maxLength: '0' //define how many character can be on one line | ||
font: 'block', //define the font face | ||
align: 'left', //define text alignment | ||
colors: ['system'], //define all colors | ||
background: 'transparent', //define the background color, you can also use `backgroundColor` here as key | ||
letterSpacing: 1, //define letter spacing | ||
lineHeight: 1, //define the line height | ||
space: true, //define if the output text should have empty lines on top and on the bottom | ||
maxLength: '0', //define how many character can be on one line | ||
}); | ||
@@ -194,2 +194,6 @@ ``` | ||
```shell | ||
$ cfonts "text" -f "console" | ||
``` | ||
- `console` [colors: 1] | ||
@@ -212,7 +216,3 @@ ![console font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/master/img/console.png) | ||
```shell | ||
$ cfonts "text" -f "3d" | ||
``` | ||
#### -a, --align | ||
@@ -235,7 +235,9 @@ Type: `<string>` | ||
Type: `<string list>` | ||
Default value: `[]` | ||
Default value: `['system']` | ||
With this setting you can set the colors for your font. Use the below color strings built in by [chalk](https://github.com/sindresorhus/chalk). | ||
Provide colors in a comma-separated string, eg: `red,blue` _(no spaces)_ | ||
The `system` color falls back to the system color of your terminal. | ||
- `system` _(default)_ | ||
- `black` | ||
@@ -248,5 +250,11 @@ - `red` | ||
- `cyan` | ||
- `white` _(default)_ | ||
- `white` | ||
- `gray` | ||
- `candy` | ||
- `redBright` | ||
- `greenBright` | ||
- `yellowBright` | ||
- `blueBright` | ||
- `magentaBright` | ||
- `cyanBright` | ||
- `whiteBright` | ||
@@ -260,15 +268,24 @@ ```shell | ||
Type: `<string>` | ||
Default value: `"Black"` | ||
Default value: `"transparent"` | ||
With this setting you can set the background colors for the output. Use the below color strings built in by [chalk](https://github.com/sindresorhus/chalk). | ||
Provide the background color from the below supported list, eg: 'White' | ||
Provide the background color from the below supported list, eg: 'white' | ||
- `Black` _(default)_ | ||
- `Red` | ||
- `Green` | ||
- `Yellow` | ||
- `Blue` | ||
- `Magenta` | ||
- `Cyan` | ||
- `White` | ||
- `transparent` _(default)_ | ||
- `black` | ||
- `red` | ||
- `green` | ||
- `yellow` | ||
- `blue` | ||
- `magenta` | ||
- `cyan` | ||
- `white` | ||
- `blackBright` | ||
- `redBright` | ||
- `greenBright` | ||
- `yellowBright` | ||
- `blueBright` | ||
- `magentaBright` | ||
- `cyanBright` | ||
- `whiteBright` | ||
@@ -357,2 +374,3 @@ ```shell | ||
## Release History | ||
* 1.2.0 - Added `transparent` and `system` as default background and color option, added `backgroundColor` as alias for `background`, upgraded deps | ||
* 1.1.3 - Fixed help text, removing old -t option | ||
@@ -381,2 +399,2 @@ * 1.1.2 - Fixed issue with older commander version #3, updated docs | ||
## License | ||
Copyright (c) 2016 Dominik Wilkowski. Licensed under the [GNU GPLv2](https://github.com/dominikwilkowski/cfonts/blob/master/LICENSE). | ||
Copyright (c) 2018 Dominik Wilkowski. Licensed under the [GNU GPLv2](https://github.com/dominikwilkowski/cfonts/blob/master/LICENSE). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
168154
4116
393
6
+ Addedansi-styles@^3.2.1
+ Addedansi-styles@3.2.1(transitive)
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedchange-case@3.1.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addeddefine-property@1.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-accessor-descriptor@1.0.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-data-descriptor@1.0.1(transitive)
+ Addedis-descriptor@1.0.3(transitive)
+ Addedis-number@3.0.0(transitive)
+ Addedkind-of@3.2.2(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedwindow-size@1.1.1(transitive)
- Removedansi-regex@1.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedbabel-runtime@6.22.0(transitive)
- Removedchalk@1.0.0(transitive)
- Removedchange-case@3.0.0(transitive)
- Removedcommander@2.9.0(transitive)
- Removedget-stdin@4.0.1(transitive)
- Removedgraceful-readlink@1.0.1(transitive)
- Removedhas-ansi@1.0.3(transitive)
- Removedregenerator-runtime@0.10.5(transitive)
- Removedstrip-ansi@2.0.1(transitive)
- Removedsupports-color@1.3.1(transitive)
- Removedwindow-size@0.3.0(transitive)
Updatedbabel-runtime@^6.26.0
Updatedchalk@^2.3.2
Updatedchange-case@^3.0.2
Updatedcommander@^2.15.1
Updatedwindow-size@^1.1.0