@typescript-calendar-lib/cli 0.2.6 → 0.2.7

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.
Files changed (2) hide show
  1. package/README.md +278 -0
  2. package/package.json +2 -5
package/README.md ADDED
@@ -0,0 +1,278 @@
1
+ # @typescript-calendar-lib/cli
2
+
3
+ Render month, year, or date-range calendars as plain text — with optional ANSI colors, themes, and color schemes. Includes a command-line binary.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install @typescript-calendar-lib/cli
9
+ # or
10
+ bun add @typescript-calendar-lib/cli
11
+ ```
12
+
13
+ ## Rendering API
14
+
15
+ ### `calendar(options: CalendarOptions): string`
16
+
17
+ Render a single month:
18
+
19
+ ```ts
20
+ import { calendar } from "@typescript-calendar-lib/cli";
21
+
22
+ console.log(calendar({ year: 2026, month: 9 }));
23
+ ```
24
+
25
+ ```
26
+ September 2026
27
+ Sun Mon Tue Wed Thu Fri Sat
28
+ 1 2 3 4 5
29
+ 6 7 8 9 10 11 12
30
+ 13 14 15 16 17 18 19
31
+ 20 21 22 23 24 25 26
32
+ 27 28 29 30
33
+ ```
34
+
35
+ ### `calendarYear(options: CalendarYearOptions): string`
36
+
37
+ Render a full year as a 4 columns × 3 rows grid:
38
+
39
+ ```ts
40
+ console.log(calendarYear({ year: 2026 }));
41
+ ```
42
+
43
+ ### `calendarRange(options: CalendarRangeOptions): string`
44
+
45
+ Render every month from `from` to `to` (inclusive), each on its own block:
46
+
47
+ ```ts
48
+ console.log(calendarRange({
49
+ from: new Date(2026, 5, 1),
50
+ to: new Date(2026, 8, 30),
51
+ }));
52
+ ```
53
+
54
+ ### Options
55
+
56
+ All options from `@typescript-calendar-lib/core` are supported, plus these CLI-specific extras:
57
+
58
+ | Option | Type | Default | Description |
59
+ | :--- | :--- | :--- | :--- |
60
+ | `theme` | `ThemeName \| CliTheme` | `"default"` | Visual theme (`"default"` \| `"modern"`) or custom theme object |
61
+ | `colorScheme` | `ColorSchemeName \| CliPalette` | `"default"` | Color scheme, active when `color: true` |
62
+ | `today` | `Date` | `new Date()` | Reference date for "today" coloring |
63
+
64
+ ## CLI Binary
65
+
66
+ The package ships a `typescript-calendar-lib` binary:
67
+
68
+ ```sh
69
+ typescript-calendar-lib # current month
70
+ typescript-calendar-lib 2026 # current month of 2026
71
+ typescript-calendar-lib 2026 9 # September 2026
72
+ ```
73
+
74
+ ### Options
75
+
76
+ ```
77
+ --theme <name> Look: default | modern (default: default)
78
+ --color-scheme <name> Colors: default | ocean | forest | sunset | mono
79
+ --color Enable ANSI colors
80
+ --locale <lang> Language: en | ja | es | de | fr | ko | zh (default: en)
81
+ --week-start <day> First weekday: sunday | monday (default: sunday)
82
+ --highlight <YYYY-MM-DD> Highlight a date (e.g. 2026-09-08)
83
+ --highlight-style <style> Highlight style: bracket | reverse (default: bracket)
84
+ -h, --help Show this help
85
+ ```
86
+
87
+ Example with `modern` theme and `ocean` color scheme:
88
+
89
+ ```sh
90
+ typescript-calendar-lib 2026 9 --theme modern --color-scheme ocean --color
91
+ ```
92
+
93
+ Localized, Monday-start, with a highlighted date:
94
+
95
+ ```sh
96
+ typescript-calendar-lib 2026 9 --locale ja --week-start monday --highlight 2026-09-08
97
+ ```
98
+
99
+ ## Themes
100
+
101
+ ### `ThemeName`
102
+
103
+ ```ts
104
+ type ThemeName = "default" | "modern";
105
+ ```
106
+
107
+ - **`"default"`** — plain text, space-separated cells, no frame
108
+ - **`"modern"`** — box-drawing frame (`┌───┬───┐` style)
109
+
110
+ ### `CliTheme`
111
+
112
+ Custom themes are plain objects:
113
+
114
+ ```ts
115
+ import type { CliTheme } from "@typescript-calendar-lib/cli";
116
+
117
+ const myTheme: CliTheme = {
118
+ cellWidth: 4,
119
+ separator: " | ",
120
+ frame: null, // or a FrameChars object for bordered layout
121
+ };
122
+ ```
123
+
124
+ | Property | Type | Description |
125
+ | :--- | :--- | :--- |
126
+ | `cellWidth` | `number` | Width of each date cell |
127
+ | `separator` | `string` | Separator between cells |
128
+ | `frame` | `FrameChars \| null` | Frame characters, or `null` for no frame |
129
+
130
+ ### `FrameChars`
131
+
132
+ ```ts
133
+ interface FrameChars {
134
+ topLeft: string;
135
+ topRight: string;
136
+ bottomLeft: string;
137
+ bottomRight: string;
138
+ h: string; // horizontal line
139
+ v: string; // vertical line
140
+ j: string; // header/body intersection (┬, ┼)
141
+ footJ: string; // bottom intersection (┴)
142
+ }
143
+ ```
144
+
145
+ The built-in `"modern"` theme uses `┌ ┐ └ ┘ ─ │ ┬ ┴`.
146
+
147
+ ### `THEMES`
148
+
149
+ ```ts
150
+ const THEMES: Record<ThemeName, CliTheme>;
151
+ ```
152
+
153
+ ### `resolveTheme(theme?)`
154
+
155
+ Resolves a `ThemeName | CliTheme` to a `CliTheme` (defaults to `"default"`).
156
+
157
+ ## Color Schemes
158
+
159
+ ### `ColorSchemeName`
160
+
161
+ ```ts
162
+ type ColorSchemeName = "default" | "ocean" | "forest" | "sunset" | "mono";
163
+ ```
164
+
165
+ - **`"default"`** — colors range (yellow) and highlight (reverse) only
166
+ - **`"ocean"`** — cyan/blue palette
167
+ - **`"forest"`** — green palette
168
+ - **`"sunset"`** — magenta/orange palette
169
+ - **`"mono"`** — grayscale
170
+
171
+ ### `CliPalette`
172
+
173
+ Each field is an ANSI foreground color code (or background code for highlight). `undefined` means "no coloring":
174
+
175
+ ```ts
176
+ interface CliPalette {
177
+ title?: number;
178
+ weekday?: number;
179
+ day?: number;
180
+ weekend?: number;
181
+ today?: number;
182
+ highlight?: number; // used with highlightStyle: "reverse"
183
+ range?: number;
184
+ frame?: number;
185
+ dim?: number;
186
+ }
187
+ ```
188
+
189
+ A custom palette can be passed directly:
190
+
191
+ ```ts
192
+ calendar({
193
+ year: 2026,
194
+ month: 9,
195
+ color: true,
196
+ colorScheme: { title: 36, range: 33, today: 33 },
197
+ });
198
+ ```
199
+
200
+ ### `COLOR_SCHEMES` and `resolveColorScheme(scheme?)`
201
+
202
+ Predefined schemes and the resolver (defaults to `"default"`).
203
+
204
+ ## Examples
205
+
206
+ ### Highlight today
207
+
208
+ ```ts
209
+ calendar({
210
+ year: 2026,
211
+ month: 9,
212
+ highlight: new Date(2026, 8, 8),
213
+ highlightStyle: "bracket", // [8]
214
+ });
215
+ ```
216
+
217
+ Reverse-video highlight requires `color: true`:
218
+
219
+ ```ts
220
+ calendar({
221
+ year: 2026,
222
+ month: 9,
223
+ highlight: new Date(2026, 8, 8),
224
+ highlightStyle: "reverse",
225
+ color: true,
226
+ });
227
+ ```
228
+
229
+ ### Range coloring
230
+
231
+ ```ts
232
+ calendar({
233
+ year: 2026,
234
+ month: 9,
235
+ range: { from: new Date(2026, 8, 1), to: new Date(2026, 8, 15) },
236
+ color: true,
237
+ });
238
+ ```
239
+
240
+ When a date is both highlighted and in range, the highlight takes precedence.
241
+
242
+ ### Plain text output
243
+
244
+ By default (`color: false`) the output contains no ANSI escape codes, so it's safe to pipe into files or other tools:
245
+
246
+ ```sh
247
+ typescript-calendar-lib 2026 9 > september.txt
248
+ ```
249
+
250
+ ## Exports
251
+
252
+ ```ts
253
+ import {
254
+ calendar,
255
+ calendarRange,
256
+ calendarYear,
257
+ COLOR_SCHEMES,
258
+ resolveColorScheme,
259
+ resolveTheme,
260
+ THEMES,
261
+ } from "@typescript-calendar-lib/cli";
262
+
263
+ import type {
264
+ CalendarOptions,
265
+ CalendarRangeOptions,
266
+ CalendarYearOptions,
267
+ CliPalette,
268
+ CliTheme,
269
+ ColorSchemeName,
270
+ FrameChars,
271
+ RenderMonthOptions,
272
+ ThemeName,
273
+ } from "@typescript-calendar-lib/cli";
274
+ ```
275
+
276
+ ## License
277
+
278
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-calendar-lib/cli",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "typescript-calendar-lib": "./dist/bin.js"
@@ -22,10 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@typescript-calendar-lib/core": "0.2.6"
26
- },
27
- "peerDependencies": {
28
- "typescript": "^5"
25
+ "@typescript-calendar-lib/core": "0.2.7"
29
26
  },
30
27
  "scripts": {
31
28
  "build": "tsdown"