@nbtca/prompt 1.5.24 → 1.6.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.
@@ -0,0 +1,64 @@
1
+ import { createHmac, randomBytes } from 'node:crypto';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { getStateDir, getWritableStateDir } from '../config/paths.js';
5
+ export const SEEN_GRADES_FILE = 'seen-grades.json';
6
+ function read(dir) {
7
+ try {
8
+ const value = JSON.parse(fs.readFileSync(path.join(dir, SEEN_GRADES_FILE), 'utf8'));
9
+ if (typeof value.salt !== 'string' || typeof value.terms !== 'object')
10
+ return undefined;
11
+ return value;
12
+ }
13
+ catch {
14
+ return undefined;
15
+ }
16
+ }
17
+ function write(dir, store) {
18
+ const file = path.join(dir, SEEN_GRADES_FILE);
19
+ fs.writeFileSync(file, JSON.stringify(store), { encoding: 'utf8', mode: 0o600 });
20
+ fs.chmodSync(file, 0o600);
21
+ }
22
+ // Only whether a course has a published result is kept, never the result, so the file reveals no grade.
23
+ function fingerprint(salt, grade) {
24
+ return createHmac('sha256', salt)
25
+ .update(`${grade.courseCode ?? ''}\u0000${grade.courseName}`)
26
+ .digest('hex')
27
+ .slice(0, 32);
28
+ }
29
+ /**
30
+ * Indexes of published grades not seen before in this term. The first look at a term seals nothing,
31
+ * so a new install does not present every old grade as new.
32
+ */
33
+ export function sealedGrades(term, grades, dir = getWritableStateDir()) {
34
+ try {
35
+ const store = read(dir) ?? { salt: randomBytes(32).toString('hex'), terms: {} };
36
+ const seen = store.terms[term];
37
+ if (!seen) {
38
+ store.terms[term] = grades
39
+ .filter((grade) => grade.grade !== null)
40
+ .map((grade) => fingerprint(store.salt, grade));
41
+ write(dir, store);
42
+ return new Set();
43
+ }
44
+ const known = new Set(seen);
45
+ return new Set(grades.flatMap((grade, index) => grade.grade !== null && !known.has(fingerprint(store.salt, grade)) ? [index] : []));
46
+ }
47
+ catch {
48
+ return new Set();
49
+ }
50
+ }
51
+ export function markGradeSeen(term, grade, dir = getStateDir()) {
52
+ try {
53
+ const store = read(dir);
54
+ if (!store)
55
+ return;
56
+ const seen = new Set(store.terms[term] ?? []);
57
+ seen.add(fingerprint(store.salt, grade));
58
+ store.terms[term] = [...seen];
59
+ write(dir, store);
60
+ }
61
+ catch {
62
+ /* best effort: the grade stays sealed next time */
63
+ }
64
+ }
@@ -0,0 +1,57 @@
1
+ import { campusIsoDate, createTimetableSchedule, } from '@nbtca/nbtcal/timetable';
2
+ import { truncate } from '../core/text.js';
3
+ import { fmt, t } from '../i18n/index.js';
4
+ const MINUTE_MS = 60_000;
5
+ const COUNTDOWN_MINUTES = 60;
6
+ const COURSE_WIDTH = 16;
7
+ function toPromptClass(occurrence, now) {
8
+ const live = occurrence.start.getTime() <= now.getTime();
9
+ const target = live ? occurrence.end : occurrence.start;
10
+ return {
11
+ state: live ? 'live' : 'next',
12
+ course: occurrence.meeting.courseName,
13
+ location: occurrence.meeting.location,
14
+ startTime: occurrence.startTime,
15
+ start: occurrence.start,
16
+ end: occurrence.end,
17
+ minutes: Math.max(1, Math.ceil((target.getTime() - now.getTime()) / MINUTE_MS)),
18
+ };
19
+ }
20
+ /** The class in progress, or else the next class later today; undefined when the day is done or the cache is unusable. */
21
+ export function promptClass(cached, now = new Date()) {
22
+ try {
23
+ const schedule = createTimetableSchedule(cached.timetable, {
24
+ weekOneMonday: cached.weekOneMonday,
25
+ });
26
+ const at = now.getTime();
27
+ const current = schedule
28
+ .occurrences()
29
+ .find((o) => o.start.getTime() <= at && at < o.end.getTime());
30
+ if (current)
31
+ return toPromptClass(current, now);
32
+ const next = schedule.next(now);
33
+ return next?.date === campusIsoDate(now) ? toPromptClass(next, now) : undefined;
34
+ }
35
+ catch {
36
+ return undefined;
37
+ }
38
+ }
39
+ export function promptLine(value, unicode) {
40
+ if (!value)
41
+ return '';
42
+ const trans = t().prompt;
43
+ const marker = value.state === 'live' ? (unicode ? '●' : '*') : unicode ? '○' : '-';
44
+ const sep = unicode ? ' · ' : ' | ';
45
+ const when = value.state === 'live'
46
+ ? fmt(trans.endsIn, { minutes: value.minutes })
47
+ : value.minutes <= COUNTDOWN_MINUTES
48
+ ? fmt(trans.startsIn, { minutes: value.minutes })
49
+ : value.startTime;
50
+ const course = truncate(value.course, COURSE_WIDTH, unicode ? '…' : '...');
51
+ return [`${marker} ${course}`, value.location, when].filter(Boolean).join(sep);
52
+ }
53
+ export function serializePromptClass(value) {
54
+ if (!value)
55
+ return null;
56
+ return { ...value, start: value.start.toISOString(), end: value.end.toISOString() };
57
+ }
@@ -2,6 +2,7 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { getWritableConfigDir, getConfigDir, getWritableStateDir, getStateDir, } from '../config/paths.js';
4
4
  import { parseLocalMonday } from '../core/calendar-day.js';
5
+ import { SEEN_GRADES_FILE } from './grade-seen.js';
5
6
  const TERM_PART_RE = /^[A-Za-z0-9_-]{1,32}$/;
6
7
  const TERM_KEY_RE = /^[A-Za-z0-9_-]{1,65}$/;
7
8
  function requireTermKey(value) {
@@ -94,12 +95,14 @@ export function loadCurrentPointer(dir) {
94
95
  return null;
95
96
  return { termKey: value.termKey, weekOneMonday: value.weekOneMonday };
96
97
  }
97
- /** Remove the cached timetables and the current-term pointer (e.g. on logout). Best-effort. */
98
+ /** Remove the cached timetables, the current-term pointer, and seen-grade fingerprints (e.g. on logout). Best-effort. */
98
99
  export function clearScheduleCache(dir) {
99
100
  const stateDir = dir ?? getStateDir();
100
101
  try {
101
102
  for (const f of fs.readdirSync(stateDir)) {
102
- if (f === 'current-term.json' || (f.startsWith('timetable-') && f.endsWith('.json'))) {
103
+ if (f === 'current-term.json' ||
104
+ f === SEEN_GRADES_FILE ||
105
+ (f.startsWith('timetable-') && f.endsWith('.json'))) {
103
106
  try {
104
107
  fs.unlinkSync(path.join(stateDir, f));
105
108
  }
@@ -0,0 +1,68 @@
1
+ import { createTimetableSchedule } from '@nbtca/nbtcal/timetable';
2
+ const EARLY_START = '08:30';
3
+ const MINUTE_MS = 60_000;
4
+ function mostCommon(counts) {
5
+ let best;
6
+ for (const entry of counts)
7
+ if (!best || entry[1] > best[1])
8
+ best = entry;
9
+ return best;
10
+ }
11
+ function add(counts, key, amount = 1) {
12
+ counts.set(key, (counts.get(key) ?? 0) + amount);
13
+ }
14
+ const hoursOf = (minutes) => Math.round(minutes / 6) / 10;
15
+ /** Counts only classes that have ended by `now`, and only club events between the first and last of them. */
16
+ export function termRecap(timetable, weekOneMonday, now, countEvents) {
17
+ let occurrences;
18
+ try {
19
+ occurrences = createTimetableSchedule(timetable, { weekOneMonday }).occurrences();
20
+ }
21
+ catch {
22
+ return undefined;
23
+ }
24
+ const held = occurrences.filter((o) => o.end.getTime() <= now.getTime());
25
+ const first = held[0];
26
+ const last = held.at(-1);
27
+ if (!first || !last)
28
+ return undefined;
29
+ const minutesByCourse = new Map();
30
+ const visitsByRoom = new Map();
31
+ const byDate = new Map();
32
+ let minutes = 0;
33
+ let earlyClasses = 0;
34
+ for (const o of held) {
35
+ const length = (o.end.getTime() - o.start.getTime()) / MINUTE_MS;
36
+ minutes += length;
37
+ add(minutesByCourse, o.meeting.courseName, length);
38
+ if (o.meeting.location)
39
+ add(visitsByRoom, o.meeting.location);
40
+ if (o.startTime < EARLY_START)
41
+ earlyClasses += 1;
42
+ const day = byDate.get(o.date) ?? [];
43
+ day.push(o);
44
+ byDate.set(o.date, day);
45
+ }
46
+ let busiestDay;
47
+ for (const [date, day] of byDate) {
48
+ if (busiestDay && day.length <= busiestDay.classes)
49
+ continue;
50
+ const to = day.reduce((latest, o) => (o.endTime > latest ? o.endTime : latest), '');
51
+ busiestDay = { date, classes: day.length, from: day[0]?.startTime ?? '', to };
52
+ }
53
+ const top = mostCommon(minutesByCourse);
54
+ const room = mostCommon(visitsByRoom);
55
+ return {
56
+ finished: held.length === occurrences.length,
57
+ progress: held.length / occurrences.length,
58
+ classes: held.length,
59
+ hours: hoursOf(minutes),
60
+ courses: minutesByCourse.size,
61
+ weeks: new Set(held.map((o) => o.week)).size,
62
+ earlyClasses,
63
+ ...(busiestDay ? { busiestDay } : {}),
64
+ ...(top ? { topCourse: { name: top[0], hours: hoursOf(top[1]) } } : {}),
65
+ ...(room ? { favoriteRoom: { name: room[0], visits: room[1] } } : {}),
66
+ ...(countEvents ? { events: countEvents(first.start, last.end) } : {}),
67
+ };
68
+ }
@@ -11,6 +11,41 @@
11
11
  "moreBelow": "{count} more below",
12
12
  "offline": "Refresh failed; showing cache"
13
13
  },
14
+ "almanac": {
15
+ "chunfen": "Spring Equinox",
16
+ "qingming": "Qingming",
17
+ "guyu": "Grain Rain",
18
+ "lixia": "Start of Summer",
19
+ "xiaoman": "Grain Buds",
20
+ "mangzhong": "Grain in Ear",
21
+ "xiazhi": "Summer Solstice",
22
+ "xiaoshu": "Minor Heat",
23
+ "dashu": "Major Heat",
24
+ "liqiu": "Start of Autumn",
25
+ "chushu": "End of Heat",
26
+ "bailu": "White Dew",
27
+ "qiufen": "Autumn Equinox",
28
+ "hanlu": "Cold Dew",
29
+ "shuangjiang": "Frost's Descent",
30
+ "lidong": "Start of Winter",
31
+ "xiaoxue": "Minor Snow",
32
+ "daxue": "Major Snow",
33
+ "dongzhi": "Winter Solstice",
34
+ "xiaohan": "Minor Cold",
35
+ "dahan": "Major Cold",
36
+ "lichun": "Start of Spring",
37
+ "yushui": "Rain Water",
38
+ "jingzhe": "Awakening of Insects",
39
+ "newYear": "New Year's Day",
40
+ "newYearsEve": "Lunar New Year's Eve",
41
+ "springFestival": "Spring Festival",
42
+ "lanternFestival": "Lantern Festival",
43
+ "midAutumn": "Mid-Autumn Festival"
44
+ },
45
+ "greeting": {
46
+ "lateNight": "It's late. Get some sleep.",
47
+ "anniversary": "NBTCA turns {years} this month."
48
+ },
14
49
  "help": {
15
50
  "title": "Keys",
16
51
  "sectionGlobal": "Anywhere",
@@ -80,6 +115,15 @@
80
115
  "dayCount": "{date} {sep} {count} events",
81
116
  "dayEmpty": "No events that day"
82
117
  },
118
+ "stars": {
119
+ "title": "The past year of events",
120
+ "repair": "repair",
121
+ "workshop": "workshop",
122
+ "conference": "conference",
123
+ "meeting": "meeting",
124
+ "birthday": "birthday",
125
+ "other": "other"
126
+ },
83
127
  "pastLoading": "Loading past events...",
84
128
  "pastEvents": "Past Events",
85
129
  "pastEventsDesc": "Recent activity history",
@@ -274,7 +318,10 @@
274
318
  "searchFooter": "Enter apply · Esc cancel",
275
319
  "upcomingFilter": "Upcoming exams",
276
320
  "attentionFilter": "Unpublished / void grades",
277
- "filtered": "Filtered"
321
+ "filtered": "Filtered",
322
+ "newTag": "new",
323
+ "revealHint": "Press Enter to reveal",
324
+ "newSummary": "{count} new"
278
325
  },
279
326
  "timetable": {
280
327
  "menuTitle": "My Timetable",
@@ -436,6 +483,34 @@
436
483
  "usage": "Usage: nbtca theme | nbtca theme icon <auto|ascii|unicode> | nbtca theme color <auto|on|off> | nbtca theme reset",
437
484
  "invalidValue": "Invalid value. Use one of:"
438
485
  },
486
+ "recap": {
487
+ "title": "Term recap",
488
+ "titleSoFar": "This term so far",
489
+ "classesLead": "This term, your timetable held",
490
+ "classesLeadSoFar": "So far this term, your timetable has held",
491
+ "classesUnit": "classes",
492
+ "classesDetail": "{hours} hours across {courses} courses and {weeks} teaching weeks.",
493
+ "earlyLead": "Classes that started before 8:30 a.m.",
494
+ "earlyUnit": "early starts",
495
+ "earlyDetail": "Every early morning counts.",
496
+ "earlyNone": "No early classes this term. Worth celebrating.",
497
+ "busiestLead": "Your fullest day was {date}, with",
498
+ "busiestDetail": "From {from} all the way to {to}.",
499
+ "topLead": "The course you spent the most time in was {course}:",
500
+ "topDetail": "Enough time to watch {films} films.",
501
+ "hoursUnit": "hours",
502
+ "roomLead": "The room on your timetable most often was {room}:",
503
+ "roomDetail": "That room probably knows you by now.",
504
+ "roomUnit": "visits",
505
+ "eventsLead": "Over the same weeks, NBTCA hosted",
506
+ "eventsUnit": "events",
507
+ "eventsDetail": "Look back at each one on the Events tab.",
508
+ "outro": "Well done this term. See you next term.",
509
+ "outroSoFar": "The term isn't over yet. Come back at the end for the full recap.",
510
+ "empty": "No classes have finished yet. Check back after the first one.",
511
+ "footerPage": "page",
512
+ "homeReady": "Your term recap is ready. Press r on the Schedule tab to see it."
513
+ },
439
514
  "language": {
440
515
  "selectLanguage": "Language",
441
516
  "zh": "简体中文 (Simplified Chinese)",
@@ -496,6 +571,12 @@
496
571
  "eventsRangeConflict": "Choose only one event range: --today, --week, or --month.",
497
572
  "unexpectedArguments": "Unexpected arguments for {command}.",
498
573
  "requiresTty": "Interactive mode requires a TTY terminal.",
499
- "requiresTtyHint": "Use `nbtca --help` for command mode."
574
+ "requiresTtyHint": "Use `nbtca --help` for command mode.",
575
+ "cmdPrompt": "Print the current or next class for a shell prompt",
576
+ "flagShell": "Print the setup line for fish, zsh, bash, or tmux"
577
+ },
578
+ "prompt": {
579
+ "endsIn": "{minutes} min left",
580
+ "startsIn": "in {minutes} min"
500
581
  }
501
582
  }
@@ -11,6 +11,41 @@
11
11
  "moreBelow": "下方还有 {count} 项",
12
12
  "offline": "无法刷新,显示上次获取的内容"
13
13
  },
14
+ "almanac": {
15
+ "chunfen": "春分",
16
+ "qingming": "清明",
17
+ "guyu": "谷雨",
18
+ "lixia": "立夏",
19
+ "xiaoman": "小满",
20
+ "mangzhong": "芒种",
21
+ "xiazhi": "夏至",
22
+ "xiaoshu": "小暑",
23
+ "dashu": "大暑",
24
+ "liqiu": "立秋",
25
+ "chushu": "处暑",
26
+ "bailu": "白露",
27
+ "qiufen": "秋分",
28
+ "hanlu": "寒露",
29
+ "shuangjiang": "霜降",
30
+ "lidong": "立冬",
31
+ "xiaoxue": "小雪",
32
+ "daxue": "大雪",
33
+ "dongzhi": "冬至",
34
+ "xiaohan": "小寒",
35
+ "dahan": "大寒",
36
+ "lichun": "立春",
37
+ "yushui": "雨水",
38
+ "jingzhe": "惊蛰",
39
+ "newYear": "元旦",
40
+ "newYearsEve": "除夕",
41
+ "springFestival": "春节",
42
+ "lanternFestival": "元宵节",
43
+ "midAutumn": "中秋节"
44
+ },
45
+ "greeting": {
46
+ "lateNight": "夜深了,早点休息。",
47
+ "anniversary": "本月是 NBTCA 创立 {years} 周年。"
48
+ },
14
49
  "help": {
15
50
  "title": "快捷键",
16
51
  "sectionGlobal": "全局",
@@ -80,6 +115,15 @@
80
115
  "dayCount": "{date} · {count} 场活动",
81
116
  "dayEmpty": "这一天没有活动"
82
117
  },
118
+ "stars": {
119
+ "title": "过去一年的活动",
120
+ "repair": "维修",
121
+ "workshop": "工作坊",
122
+ "conference": "大会",
123
+ "meeting": "例会",
124
+ "birthday": "生日",
125
+ "other": "其他"
126
+ },
83
127
  "pastLoading": "正在加载历史活动...",
84
128
  "pastEvents": "历史活动",
85
129
  "pastEventsDesc": "近期活动记录",
@@ -274,7 +318,10 @@
274
318
  "searchFooter": "Enter 确认 · Esc 取消",
275
319
  "upcomingFilter": "待参加的考试",
276
320
  "attentionFilter": "待公布或作废的成绩",
277
- "filtered": "筛选中"
321
+ "filtered": "筛选中",
322
+ "newTag": "新",
323
+ "revealHint": "按 Enter 揭晓",
324
+ "newSummary": "{count} 门新成绩"
278
325
  },
279
326
  "timetable": {
280
327
  "menuTitle": "我的课表",
@@ -436,6 +483,34 @@
436
483
  "usage": "用法: nbtca theme | nbtca theme icon <auto|ascii|unicode> | nbtca theme color <auto|on|off> | nbtca theme reset",
437
484
  "invalidValue": "无效取值,可选:"
438
485
  },
486
+ "recap": {
487
+ "title": "学期回顾",
488
+ "titleSoFar": "本学期至今",
489
+ "classesLead": "这学期,课表上一共有",
490
+ "classesLeadSoFar": "这学期到今天为止,课表上已经过去了",
491
+ "classesUnit": "节课",
492
+ "classesDetail": "合计 {hours} 小时,分布在 {courses} 门课和 {weeks} 个教学周里。",
493
+ "earlyLead": "其中八点半以前开始的早课有",
494
+ "earlyUnit": "节",
495
+ "earlyDetail": "每一个早起的清晨都算数。",
496
+ "earlyNone": "这学期没有早课,值得庆祝。",
497
+ "busiestLead": "最满的一天是 {date},一共排了",
498
+ "busiestDetail": "从 {from} 一直排到 {to}。",
499
+ "topLead": "陪你最久的一门课是《{course}》,加起来有",
500
+ "topDetail": "这些时间足够看完 {films} 部电影。",
501
+ "hoursUnit": "小时",
502
+ "roomLead": "课表里出现最多的教室是 {room},一共去了",
503
+ "roomDetail": "这间教室大概也记住你了。",
504
+ "roomUnit": "次",
505
+ "eventsLead": "同一段时间里,NBTCA 办了",
506
+ "eventsUnit": "场活动",
507
+ "eventsDetail": "在 Events 页可以回看每一场。",
508
+ "outro": "这学期辛苦了,下学期见。",
509
+ "outroSoFar": "学期还在继续,期末再来看完整的回顾。",
510
+ "empty": "还没有上完的课,等第一节课结束后再来看吧。",
511
+ "footerPage": "翻页",
512
+ "homeReady": "学期回顾已经准备好了,到课表页按 r 就能看。"
513
+ },
439
514
  "language": {
440
515
  "selectLanguage": "语言",
441
516
  "zh": "简体中文",
@@ -496,6 +571,12 @@
496
571
  "eventsRangeConflict": "活动时间范围只能选择一个:--today、--week 或 --month。",
497
572
  "unexpectedArguments": "{command} 不接受多余参数。",
498
573
  "requiresTty": "交互模式需要 TTY 终端。",
499
- "requiresTtyHint": "使用 `nbtca --help` 查看命令模式。"
574
+ "requiresTtyHint": "使用 `nbtca --help` 查看命令模式。",
575
+ "cmdPrompt": "为 shell 提示符输出正在上或即将开始的课",
576
+ "flagShell": "输出接入 fish、zsh、bash 或 tmux 的配置"
577
+ },
578
+ "prompt": {
579
+ "endsIn": "还剩 {minutes} 分钟",
580
+ "startsIn": "{minutes} 分钟后"
500
581
  }
501
582
  }
package/dist/index.js CHANGED
@@ -1,7 +1,14 @@
1
1
  #!/usr/bin/env node
2
- if (process.argv.slice(2).includes('--plain')) {
2
+ const argv = process.argv.slice(2);
3
+ if (argv.includes('--plain')) {
3
4
  delete process.env['FORCE_COLOR'];
4
5
  process.env['NO_COLOR'] = '1';
5
6
  }
6
- await import('./cli.js');
7
+ if (argv[0] === 'prompt' && !argv.includes('--help')) {
8
+ const { runPromptCommand } = await import('./prompt.js');
9
+ process.exitCode = runPromptCommand(argv.slice(1));
10
+ }
11
+ else {
12
+ await import('./cli.js');
13
+ }
7
14
  export {};
package/dist/prompt.js ADDED
@@ -0,0 +1,52 @@
1
+ import { resolveIconMode } from './config/preferences.js';
2
+ import { promptClass, promptLine, serializePromptClass } from './features/prompt-line.js';
3
+ import { peekSchedule } from './features/schedule-view.js';
4
+ import { fmt, t } from './i18n/index.js';
5
+ const SHELL_SETUP = {
6
+ fish: 'function fish_right_prompt; nbtca prompt; end',
7
+ zsh: "setopt prompt_subst\nRPROMPT='$(nbtca prompt)'",
8
+ bash: 'PS1=\'$(c=$(nbtca prompt); [ -n "$c" ] && printf "%s " "$c")\'"$PS1"',
9
+ tmux: "set -g status-interval 30\nset -g status-right '#(nbtca prompt) %H:%M'",
10
+ };
11
+ function unicodeWanted(plain) {
12
+ if (plain)
13
+ return false;
14
+ const mode = resolveIconMode();
15
+ if (mode !== 'auto')
16
+ return mode === 'unicode';
17
+ const locale = `${process.env['LC_ALL'] ?? ''} ${process.env['LANG'] ?? ''}`.toLowerCase();
18
+ return /utf-?8/.test(locale);
19
+ }
20
+ function fail(message) {
21
+ process.stderr.write(message + '\n');
22
+ return 1;
23
+ }
24
+ /** Runs on every shell prompt, so it reads only the local cache and never loads the full CLI. */
25
+ export function runPromptCommand(argv) {
26
+ const cli = t().cli;
27
+ const flags = argv.filter((arg) => arg.startsWith('--'));
28
+ const extra = argv.find((arg) => !arg.startsWith('--'));
29
+ if (extra !== undefined)
30
+ return fail(fmt(cli.unexpectedArguments, { command: 'prompt' }));
31
+ const unknown = flags.find((flag) => flag !== '--json' && flag !== '--plain' && !flag.startsWith('--shell='));
32
+ if (unknown !== undefined)
33
+ return fail(fmt(cli.invalidFlag, { flag: unknown }));
34
+ const shellFlag = flags.find((flag) => flag.startsWith('--shell='));
35
+ if (shellFlag !== undefined) {
36
+ const setup = SHELL_SETUP[shellFlag.slice('--shell='.length)];
37
+ if (setup === undefined)
38
+ return fail(fmt(cli.invalidFlag, { flag: shellFlag }));
39
+ process.stdout.write(setup + '\n');
40
+ return 0;
41
+ }
42
+ const schedule = peekSchedule();
43
+ const value = schedule ? promptClass(schedule) : undefined;
44
+ if (flags.includes('--json')) {
45
+ process.stdout.write(JSON.stringify(serializePromptClass(value)) + '\n');
46
+ return 0;
47
+ }
48
+ const line = promptLine(value, unicodeWanted(flags.includes('--plain')));
49
+ if (line)
50
+ process.stdout.write(line + '\n');
51
+ return 0;
52
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nbtca/prompt",
3
- "version": "1.5.24",
3
+ "version": "1.6.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "exports": {