-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
executable file
·109 lines (105 loc) · 2.48 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env node
// ./index.js -f tux 'Hello World!'
// ______________
// < Hello World! >
// --------------
// \
// \
// .--.
// |o_o |
// |:_/ |
// // \ \
// (| | )
// /'\_ _/`\
// \___)=(___/
//
// Help output
// -----------
//
// ./index.js --help
// Usage: cowsay <command> <text> [options]
//
// Configurable speaking cow (and a bit more)
//
// Commands:
// list List the cow templates.
//
// Options:
// -e, --eye <str> The eye string.
// -T, --tongue <str> The tongue string.
// -f, --cowfile <cow> The cowfile.
// -v, --version Displays version information.
// -h, --help Displays this help.
//
// Examples:
// $ cowsay 'Hello there!'
// $ cowsay -e '*-' 'Heyyy!
// $ cowsay -T '++' 'I have a nice tongue!
//
// Well, this is just a tiny example how to use Tilda.
// Documentation can be found at https://github.com/IonicaBizau/tilda.
"use strict";
const Tilda = require("../lib")
, cowsay = require("cowsay")
;
let p = new Tilda({
name: "cowsay"
, version: "1.0.0"
, description: "Configurable speaking cow (and a bit more)"
, documentation: "https://github.com/IonicaBizau/tilda"
, examples: [
"cowsay 'Hello there!'"
, "cowsay -e '*-' 'Heyyy!"
, "cowsay -T '++' 'I have a nice tongue!"
]
, notes: "Well, this is just a tiny example how to use Tilda."
, args: [{
name: "text"
, type: String
, desc: "The text to display."
, stdin: true
}]
}, {
stdin: true
}).option([
{
opts: ["eye", "e"]
, desc: "The eye string."
, name: "str"
}
, {
opts: ["tongue", "T"]
, desc: "The tongue string."
, name: "str"
}
, {
opts: ["cowfile", "f"]
, desc: "The cowfile."
, name: "cow"
, default: "default"
}
]).action([
{
name: "list"
, desc: "List the cow templates."
, options: [
{
opts: ["list", "l"],
desc: "Display as list",
}
]
}
]).on("list", action => {
cowsay.list((err, list) => {
if (err) { return this.exit(err); }
let str = list.join(action.options.list.is_provided ? "\n" : ", ")
console.log(str);
});
}).main(action => {
console.log(cowsay.say({
text: action.stdinData || action.args.text || " "
, e: action.options.eye.value
, T: action.options.tongue.value
, f: action.options.cowfile.value
}));
});