1 | #!/usr/bin/env node
|
2 |
|
3 | /**
|
4 | * fur bin script.
|
5 | */
|
6 | 'use strict'
|
7 |
|
8 | const program = require('commander')
|
9 | const pkg = require('../package')
|
10 | const Fur = require('../lib/fur')
|
11 | const co = require('co')
|
12 |
|
13 | program
|
14 | .version(pkg[ 'version' ])
|
15 |
|
16 | // =========================
|
17 | // Handle `banner` command
|
18 | // =========================
|
19 | program
|
20 | .command("banner <filename>")
|
21 | .description("Generate a banner.")
|
22 | .option('-c, --color <color>', "Color expression string or color theme name.")
|
23 | .option('-s, --shape <shape>', "Banner style.")
|
24 | .option('-f, --font <font>', "Font file name or font theme name.")
|
25 | .option('-F, --font-size <fontSize>', "Size of font.")
|
26 | .option('-H, --height <height>', "Banner height.")
|
27 | .option('-o, --format <format>', "File format. 'svg' or 'png'.")
|
28 | .option('-t, --text <text>', "Banner text.")
|
29 | .option('-W, --width <width>', "Banner width.")
|
30 | .option('-v, --verbose', "Emit verbose log.")
|
31 | .action((filename, options) => {
|
32 | const fur = new Fur({})
|
33 | fur.banner(filename, options)
|
34 | .then(() => process.exit(0))
|
35 | .catch((e) => {
|
36 | console.error(e)
|
37 | process.exit(1)
|
38 | })
|
39 | })
|
40 |
|
41 | // =========================
|
42 | // Handle `favicon` command
|
43 | // =========================
|
44 | program
|
45 | .command("favicon <filename>")
|
46 | .description("Generate a favicon.")
|
47 | .option('-c, --color <color>', "Color expression string or color theme name.")
|
48 | .option('-f, --font <font>', "Font file name or font theme name.")
|
49 | .option('-F, --font-size <fontSize>', "Size of font.")
|
50 | .option('-S, --size <size>', "Favicon size.")
|
51 | .option('-s, --shape <shape>', "Banner style.")
|
52 | .option('-t, --text <text>', "Favicon text.")
|
53 | .option('-o, --format <format>', "File format. 'svg' or 'png'.")
|
54 | .option('-v, --verbose', "Emit verbose log.")
|
55 | .action((filename, options) => {
|
56 | const fur = new Fur({})
|
57 | fur.favicon(filename, options)
|
58 | .then(() => process.exit(0))
|
59 | .catch((e) => {
|
60 | console.error(e)
|
61 | process.exit(1)
|
62 | })
|
63 | })
|
64 |
|
65 | program
|
66 | .parse(process.argv)
|
67 |
|
68 | if (program.args.length === 0) {
|
69 | program.help()
|
70 | }
|