moodlet 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David Winalda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # moodlet
2
+
3
+ A tiny, dependency-free CLI that prints **ASCII moods** in your terminal.
4
+
5
+ No dependencies.
6
+ No configuration.
7
+ Just moods.
8
+
9
+ ---
10
+
11
+ ## Install
12
+
13
+ ### Run instantly (no install)
14
+
15
+ ```bash
16
+ npx moodlet happy
17
+ ```
18
+
19
+ Install globally
20
+
21
+ ```bash
22
+ npm install -g moodlet
23
+ mm happy
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Usage
29
+
30
+ ```bash
31
+ mm <mood>
32
+ mm --list | -l
33
+ mm --random | -r
34
+ mm --help | -h
35
+ ```
36
+
37
+ Examples
38
+
39
+ ```bash
40
+ mm happy
41
+ mm sad
42
+ mm tired
43
+ mm sleepy # alias -> tired
44
+ mm ok # alias -> chill
45
+ mm --list
46
+ mm --random
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Output
52
+
53
+ `mm happy`
54
+
55
+ ```code
56
+ ╔════════════════╗
57
+ ║ ◕ ◕ ║
58
+ ║ ▿ ║
59
+ ║ \______/ ║
60
+ ╚════════════════╝
61
+ ```
62
+
63
+ `mm sad`
64
+
65
+ ```code
66
+ ╔════════════════╗
67
+ ║ ╥ ╥ ║
68
+ ║ ▄▄▄ ║
69
+ ║ ▄████▄ ║
70
+ ╚════════════════╝
71
+ ```
72
+
73
+ `mm love`
74
+
75
+ ```code
76
+ ╔════════════════╗
77
+ ║ ♥ ♥ ║
78
+ ║ ▿ ║
79
+ ║ \\______/ ║
80
+ ╚════════════════╝
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Available moods
86
+
87
+ Run:
88
+
89
+ ```bash
90
+ mm --list
91
+ ```
92
+
93
+ Example moods:
94
+
95
+ - happy
96
+ - sad
97
+ - tired
98
+ - angry
99
+ - love
100
+ - confused
101
+ - excited
102
+ - chill
103
+ - stressed
104
+
105
+ ---
106
+
107
+ ## Aliases
108
+
109
+ Some inputs are mapped automatically to a mood:
110
+
111
+ | Input | Mapped to |
112
+ | ------ | --------- |
113
+ | ok | chill |
114
+ | cool | chill |
115
+ | relax | chill |
116
+ | sleepy | tired |
117
+ | mad | angry |
118
+ | rage | angry |
119
+ | yay | excited |
120
+ | wtf | confused |
121
+ | hmm | confused |
122
+ | panic | stressed |
123
+
124
+ ---
125
+
126
+ ## Why moodlet?
127
+
128
+ - Big multiline ASCII (easy to read)
129
+ - Terminal-native
130
+ - Zero dependencies
131
+ - Fast and fun
132
+
133
+ ---
134
+
135
+ ## Development
136
+
137
+ Requirements
138
+
139
+ - Node.js 18+
140
+
141
+ ## Setup
142
+
143
+ ```bash
144
+ git clone https://github.com/<your-username>/moodlet.git
145
+ cd moodlet
146
+ npm install
147
+ ```
148
+
149
+ > This project has no runtime dependencies. `npm install` is only for local workflows.
150
+
151
+ ### Run locally
152
+
153
+ ```bash
154
+ node bin/moodlet.js happy
155
+ ```
156
+
157
+ Or link it globally while developing:
158
+
159
+ ```bash
160
+ npm link
161
+ mm happy
162
+ ```
163
+
164
+ Unlink when done:
165
+
166
+ ```bash
167
+ npm unlink -g moodlet
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Tests
173
+
174
+ Uses Node’s built-in test runner:
175
+
176
+ ```bash
177
+ node --test
178
+ ```
179
+
180
+ ---
181
+
182
+ Project structure
183
+
184
+ ```txt
185
+ moodlet/
186
+ bin/
187
+ mm.js
188
+ src/
189
+ cli.js
190
+ engine.js
191
+ moods.js
192
+ test/
193
+ engine.test.js
194
+ package.json
195
+ README.md
196
+ LICENSE
197
+ ```
198
+
199
+ ---
200
+
201
+ ## License
202
+
203
+ MIT
package/bin/moodlet.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { runCli } from "../src/cli.js";
3
+
4
+ runCli(process.argv.slice(2));
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "moodlet",
3
+ "version": "0.1.0",
4
+ "description": "A CLI that prints ASCII moods",
5
+ "bin": {
6
+ "mm": "bin/moodlet.js"
7
+ },
8
+ "scripts": {
9
+ "test": "node --test"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/davidwinalda/moodlet.git"
14
+ },
15
+ "keywords": [
16
+ "cli",
17
+ "ascii",
18
+ "mood",
19
+ "fun",
20
+ "terminal"
21
+ ],
22
+ "files": [
23
+ "bin",
24
+ "src",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "author": "David Winalda",
29
+ "license": "MIT",
30
+ "type": "module",
31
+ "engines": {
32
+ "node": ">=18"
33
+ }
34
+ }
package/src/cli.js ADDED
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Supports:
3
+ * - mm happy
4
+ * - mm --list
5
+ * - mm --random
6
+ * - mm --help
7
+ */
8
+
9
+ import { getMoodArt, listMoods } from "./engine.js";
10
+
11
+ /**
12
+ * Map short flags to long flags
13
+ */
14
+ const FLAG_ALIASES = {
15
+ "-h": "--help",
16
+ "-l": "--list",
17
+ "-r": "--random",
18
+ };
19
+
20
+ /**
21
+ * Normalize flags so CLI logic only deals with long flags
22
+ */
23
+ function normalizeFlags(flags) {
24
+ const normalized = new Set();
25
+ for (const f of flags) {
26
+ normalized.add(FLAG_ALIASES[f] ?? f);
27
+ }
28
+ return normalized;
29
+ }
30
+
31
+ function printHelp() {
32
+ console.log(
33
+ `
34
+ mm — print an ASCII mood
35
+
36
+ Usage:
37
+ mm <mood>
38
+ mm --random | -r
39
+ mm --list | -l
40
+ mm --help | -h
41
+
42
+ Examples:
43
+ mm happy
44
+ mm sleepy
45
+ mm --random
46
+ mm -r
47
+ mm --list
48
+ mm -l
49
+ mm --help
50
+ mm -h
51
+ `.trim(),
52
+ );
53
+ }
54
+
55
+ function parseArgs(argv) {
56
+ const flags = new Set();
57
+ const positional = [];
58
+
59
+ for (const arg of argv) {
60
+ if (arg.startsWith("-")) flags.add(arg);
61
+ else positional.push(arg);
62
+ }
63
+
64
+ return { flags, positional };
65
+ }
66
+
67
+ export function runCli(argv) {
68
+ let { flags, positional } = parseArgs(argv);
69
+
70
+ flags = normalizeFlags(flags);
71
+
72
+ // Help
73
+ if (flags.has("--help")) {
74
+ printHelp();
75
+ process.exit(0);
76
+ }
77
+
78
+ // List moods
79
+ if (flags.has("--list")) {
80
+ console.log(listMoods().join("\n"));
81
+ process.exit(0);
82
+ }
83
+
84
+ // Random mood
85
+ if (flags.has("--random")) {
86
+ const moods = listMoods();
87
+ const mood = moods[Math.floor(Math.random() * moods.length)];
88
+ const res = getMoodArt(mood);
89
+ console.log(res.art);
90
+ process.exit(0);
91
+ }
92
+
93
+ // Mood from positional argument
94
+ const moodInput = positional.join(" ");
95
+
96
+ if (!moodInput) {
97
+ console.error("Error: No mood specified. Use --help for usage.");
98
+ process.exit(1);
99
+ }
100
+
101
+ const res = getMoodArt(moodInput);
102
+ if (!res.ok) {
103
+ console.error(`Error: ${res.error}`);
104
+ process.exit(1);
105
+ }
106
+
107
+ console.log(res.art);
108
+ }
package/src/engine.js ADDED
@@ -0,0 +1,69 @@
1
+ import { MOODS, ALIASES } from "./moods.js";
2
+
3
+ /**
4
+ * Normalize user input
5
+ */
6
+ export function normalizeInput(input) {
7
+ return String(input ?? "")
8
+ .trim()
9
+ .toLowerCase()
10
+ .replace(/\s+/g, " ");
11
+ }
12
+
13
+ /**
14
+ * Resolve a mood key from user input
15
+ * - Direct mood: "happy" -> "happy"
16
+ * - Alias mood: "ok" -> "chill" or "sleepy" -> "tired"
17
+ */
18
+ export function resolveMoodKey(input) {
19
+ const key = normalizeInput(input);
20
+ if (!key) return null;
21
+
22
+ if (MOODS[key]) return key;
23
+ if (ALIASES[key] && MOODS[ALIASES[key]]) {
24
+ return ALIASES[key];
25
+ }
26
+ return null;
27
+ }
28
+
29
+ /**
30
+ * Pick deterministic item using a number of seed (for tests),
31
+ * Otherwise pick random item.
32
+ */
33
+ export function pickOne(list, seed = null) {
34
+ if (!Array.isArray(list) || list.length === 0) return null;
35
+
36
+ if (typeof seed === "number" && Number.isFinite(seed)) {
37
+ const idx = Math.abs(Math.floor(seed)) % list.length;
38
+ return list[idx];
39
+ }
40
+
41
+ return list[Math.floor(Math.random() * list.length)];
42
+ }
43
+
44
+ /**
45
+ * Get an ASCII mood output for a given mood input.
46
+ * Returns:
47
+ * - { ok: true, moodKey, art }
48
+ * - { ok: false, error }
49
+ */
50
+ export function getMoodArt(input, { seed = null } = {}) {
51
+ const moodKey = resolveMoodKey(input);
52
+
53
+ if (!moodKey) {
54
+ return {
55
+ ok: false,
56
+ error: `Unknown mood "${normalizeInput(input)}". Use --list to see available moods.`,
57
+ };
58
+ }
59
+
60
+ const art = pickOne(MOODS[moodKey], seed);
61
+ return { ok: true, moodKey, art };
62
+ }
63
+
64
+ /**
65
+ * List the available moods as an array of keys.
66
+ */
67
+ export function listMoods() {
68
+ return Object.keys(MOODS).sort();
69
+ }
package/src/moods.js ADDED
@@ -0,0 +1,105 @@
1
+ export const MOODS = {
2
+ happy: [
3
+ `
4
+ ╔════════════════╗
5
+ ║ ◕ ◕ ║
6
+ ║ ▿ ║
7
+ ║ \\______/ ║
8
+ ╚════════════════╝
9
+ `,
10
+ ],
11
+
12
+ sad: [
13
+ `
14
+ ╔════════════════╗
15
+ ║ ╥ ╥ ║
16
+ ║ ▄▄▄ ║
17
+ ║ ▄████▄ ║
18
+ ╚════════════════╝
19
+ `,
20
+ ],
21
+
22
+ tired: [
23
+ `
24
+ ╔════════════════╗
25
+ ║ - - ║
26
+ ║ ___ ║
27
+ ║ z Z z ║
28
+ ╚════════════════╝
29
+ `,
30
+ ],
31
+
32
+ angry: [
33
+ `
34
+ ╔════════════════╗
35
+ ║ > < ║
36
+ ║ █████████ ║
37
+ ║ ███ ║
38
+ ╚════════════════╝
39
+ `,
40
+ ],
41
+
42
+ love: [
43
+ `
44
+ ╔════════════════╗
45
+ ║ ♥ ♥ ║
46
+ ║ ▿ ║
47
+ ║ \\______/ ║
48
+ ╚════════════════╝
49
+ `,
50
+ ],
51
+
52
+ confused: [
53
+ `
54
+ ╔════════════════╗
55
+ ║ ⊙ ⊙ ║
56
+ ║ ___ ║
57
+ ║ ( ? ) ║
58
+ ╚════════════════╝
59
+ `,
60
+ ],
61
+
62
+ excited: [
63
+ `
64
+ ╔════════════════╗
65
+ ║ ★ ★ ║
66
+ ║ ▿ ║
67
+ ║ \\______/ ║
68
+ ╚════════════════╝
69
+ `,
70
+ ],
71
+
72
+ chill: [
73
+ `
74
+ ╔════════════════╗
75
+ ║ ■ ■ ║
76
+ ║ ─── ║
77
+ ║ (____) ║
78
+ ╚════════════════╝
79
+ `,
80
+ ],
81
+
82
+ stressed: [
83
+ `
84
+ ╔════════════════╗
85
+ ║ @ @ ║
86
+ ║ ███ ║
87
+ ║ ▄████▄ ║
88
+ ╚════════════════╝
89
+ `,
90
+ ],
91
+ };
92
+
93
+ // Aliases stay exactly the same
94
+ export const ALIASES = {
95
+ ok: "chill",
96
+ cool: "chill",
97
+ relax: "chill",
98
+ sleepy: "tired",
99
+ mad: "angry",
100
+ rage: "angry",
101
+ yay: "excited",
102
+ wtf: "confused",
103
+ hmm: "confused",
104
+ panic: "stressed",
105
+ };