Skip to content

Commit 758d6e9

Browse files
committed
Print flowers 🌼 🌸
1 parent 8013777 commit 758d6e9

File tree

5 files changed

+39
-9
lines changed

5 files changed

+39
-9
lines changed

Diff for: cli.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
const { getCities, getPollenData } = require('./client');
66
const { prompt } = require('inquirer');
77
const { URL } = require('url');
8+
const ansi = require('ansi2')(process.stdout);
89
const argv = require('minimist')(process.argv.slice(2));
910
const chalk = require('chalk');
11+
const flowers = require('./flowers');
1012
const opn = require('opn');
1113
const pkg = require('./package.json');
1214
const print = require('./printer');
@@ -47,7 +49,7 @@ async function program(options = getOptions(argv)) {
4749
} = options;
4850

4951
if (showVersion) return console.log(pkg.version);
50-
if (showHelp) return console.log(help);
52+
if (showHelp) return outputHelp(help, flowers);
5153

5254
const cities = await getCities();
5355
const city = options.city || await selectCity(cities);
@@ -87,6 +89,16 @@ async function selectCity(cities) {
8789
return city;
8890
}
8991

92+
function outputHelp(help, logo, margin = 66) {
93+
help.split('\n').forEach((line, row) => {
94+
ansi.write(line);
95+
const logoLine = logo[row];
96+
if (!logoLine) return ansi.write('\n');
97+
ansi.restartLine(margin).write(logoLine);
98+
ansi.write('\n');
99+
});
100+
}
101+
90102
const replacements = [
91103
[/[čć]/g, 'c'],
92104
[/dž/g, 'dz'],

Diff for: flowers.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
const chalk = require('chalk');
4+
const lines = str => str.split('\n').filter(line => line.length > 0);
5+
6+
module.exports = lines(chalk`
7+
{bold.yellow _,-._}
8+
{bold.yellow / \\}{whiteBright _}{bold.yellow / \\} {bold.red _,-._}
9+
{bold.yellow >-}{whiteBright (_)}{bold.yellow -<} {bold.red / \\}{whiteBright _}{bold.red / \\}
10+
{bold.yellow \\_/ \\_/} {bold.red >-}{whiteBright (_)}{bold.red -<}
11+
{bold.yellow \`-'} {bold.red \\_/ \\_/}
12+
{bold.red \`-'}
13+
`);

Diff for: package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"homepage": "https://github.com/vladimyr/peludna-prognoza",
3232
"dependencies": {
33+
"ansi2": "^1.0.0",
3334
"chalk": "^2.4.1",
3435
"cli-table": "^0.3.1",
3536
"elementtree": "^0.1.7",

Diff for: readme.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,18 @@ $ npx peludna-prognoza
2020

2121
```
2222
$ peludna-prognoza --help
23-
24-
peludna-prognoza v1.0.0
25-
26-
Usage:
27-
$ peludna-prognoza [city]
28-
$ peludna-prognoza -c <city>
23+
_,-._
24+
peludna-prognoza v1.0.0 / \_/ \ _,-._
25+
>-(_)-< / \_/ \
26+
Usage: \_/ \_/ >-(_)-<
27+
$ peludna-prognoza [city] `-' \_/ \_/
28+
$ peludna-prognoza -c <city> `-'
2929
3030
Options:
3131
-c, --city Select city [string]
3232
-j, --json Output data in JSON format [boolean]
33-
-j, --xml Output data in XML format [boolean]
33+
-x, --xml Output data in XML format [boolean]
3434
-w, --web Show data using web browser [boolean]
35-
-h, --help Show help [boolean]
3635
-v, --version Show version number [boolean]
3736
3837
Homepage: https://github.com/vladimyr/peludna-prognoza

0 commit comments

Comments
 (0)