fortune-cli 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/index.js +92 -0
- package/package.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# fortune-cli 🎱
|
|
2
|
+
|
|
3
|
+
Get random fortunes, quotes, and jokes from your terminal!
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g fortune-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
fortune # Show all (fortune + quote + joke)
|
|
15
|
+
fortune fortune # Just a fortune
|
|
16
|
+
fortune quote # Just a quote
|
|
17
|
+
fortune joke # Just a joke
|
|
18
|
+
fortune help # Show help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
🔮 Your Fortune:
|
|
25
|
+
"A beautiful, smart, and loving person will be coming into your life."
|
|
26
|
+
|
|
27
|
+
💬 Random Quote:
|
|
28
|
+
"The only way to do great work is to love what you do."
|
|
29
|
+
— Steve Jobs
|
|
30
|
+
|
|
31
|
+
😂 Random Joke:
|
|
32
|
+
Why do programmers always mix up Halloween and Christmas?
|
|
33
|
+
Because Oct 31 = Dec 25
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Made with 🫶 by Oscar
|
package/index.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const FORTUNES = [
|
|
4
|
+
"A beautiful, smart, and loving person will be coming into your life.",
|
|
5
|
+
"Your hard work will pay off soon. Keep pushing forward!",
|
|
6
|
+
"A thrilling time is in your immediate future.",
|
|
7
|
+
"You will soon become surrounded by good friends and laughter.",
|
|
8
|
+
"An unexpected event will bring you fortune and luck.",
|
|
9
|
+
"Your creativity will lead you to success.",
|
|
10
|
+
"A surprise waiting for you in the east.",
|
|
11
|
+
"Something you lost will soon be found.",
|
|
12
|
+
"Great things await you in the weeks ahead.",
|
|
13
|
+
"Your smile is a treasure to all who know you."
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const QUOTES = [
|
|
17
|
+
{ text: "The only way to do great work is to love what you do.", author: "Steve Jobs" },
|
|
18
|
+
{ text: "Innovation distinguishes between a leader and a follower.", author: "Steve Jobs" },
|
|
19
|
+
{ text: "Stay hungry, stay foolish.", author: "Steve Jobs" },
|
|
20
|
+
{ text: "Code is like humor. When you have to explain it, it's bad.", author: "Cory House" },
|
|
21
|
+
{ text: "First, solve the problem. Then, write the code.", author: "John Johnson" },
|
|
22
|
+
{ text: "Experience is the name everyone gives to their mistakes.", author: "Oscar Wilde" },
|
|
23
|
+
{ text: "The best error is the one you don't make.", author: "Anonymous" }
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const JOKES = [
|
|
27
|
+
{ setup: "Why do programmers always mix up Halloween and Christmas?", punchline: "Because Oct 31 = Dec 25" },
|
|
28
|
+
{ setup: "How many programmers does it take to change a light bulb?", punchline: "None, that's a hardware problem" },
|
|
29
|
+
{ setup: "Why was the JavaScript developer sad?", punchline: "Because he didn't Node how to Express himself" },
|
|
30
|
+
{ setup: "What do you call a fake noodle?", punchline: "An impasta" },
|
|
31
|
+
{ setup: "Why do CSS developers make good artists?", punchline: "Because they have a lot of flex" }
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const COLORS = {
|
|
35
|
+
reset: '\x1b[0m',
|
|
36
|
+
bright: '\x1b[1m',
|
|
37
|
+
cyan: '\x1b[36m',
|
|
38
|
+
yellow: '\x1b[33m',
|
|
39
|
+
green: '\x1b[32m',
|
|
40
|
+
magenta: '\x1b[35m'
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
function random(arr) {
|
|
44
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function fortune() {
|
|
48
|
+
const f = random(FORTUNES);
|
|
49
|
+
console.log(`${COLORS.cyan}🔮 ${COLORS.bright}Your Fortune:${COLORS.reset}`);
|
|
50
|
+
console.log(` "${COLORS.yellow}${f}${COLORS.reset}"\n`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function quote() {
|
|
54
|
+
const q = random(QUOTES);
|
|
55
|
+
console.log(`${COLORS.cyan}💬 ${COLORS.bright}Random Quote:${COLORS.reset}`);
|
|
56
|
+
console.log(` "${COLORS.yellow}${q.text}${COLORS.reset}"`);
|
|
57
|
+
console.log(` — ${COLORS.green}${q.author}${COLORS.reset}\n`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function joke() {
|
|
61
|
+
const j = random(JOKES);
|
|
62
|
+
console.log(`${COLORS.magenta}😂 ${COLORS.bright}Random Joke:${COLORS.reset}`);
|
|
63
|
+
console.log(` ${j.setup}`);
|
|
64
|
+
console.log(` ${COLORS.green}${j.punchline}${COLORS.reset}\n`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function all() {
|
|
68
|
+
fortune();
|
|
69
|
+
quote();
|
|
70
|
+
joke();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const args = process.argv.slice(2);
|
|
74
|
+
const cmd = args[0] || 'all';
|
|
75
|
+
|
|
76
|
+
switch(cmd) {
|
|
77
|
+
case 'fortune': case 'f': fortune(); break;
|
|
78
|
+
case 'quote': case 'q': quote(); break;
|
|
79
|
+
case 'joke': case 'j': joke(); break;
|
|
80
|
+
case 'all': case 'a': case undefined: all(); break;
|
|
81
|
+
case 'help': case 'h':
|
|
82
|
+
console.log(`${COLORS.cyan}Usage: fortune [command]${COLORS.reset}`);
|
|
83
|
+
console.log(' fortune, f - Show a random fortune');
|
|
84
|
+
console.log(' quote, q - Show a random quote');
|
|
85
|
+
console.log(' joke, j - Show a random joke');
|
|
86
|
+
console.log(' all, a - Show all of the above (default)');
|
|
87
|
+
console.log(' help, h - Show this help');
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
console.log(`Unknown command: ${cmd}. Run 'fortune help' for usage.`);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fortune-cli",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Get random fortunes, quotes, and jokes from the command line",
|
|
5
|
+
"bin": {
|
|
6
|
+
"fortune": "./index.js"
|
|
7
|
+
},
|
|
8
|
+
"preferGlobal": true,
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node index.js"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"axios": "^1.6.0"
|
|
14
|
+
}
|
|
15
|
+
}
|