icoa-cli 2.15.3 → 2.15.5
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/dist/commands/exam.js +6 -3
- package/dist/commands/lang.js +19 -3
- package/dist/repl.js +25 -0
- package/package.json +1 -1
package/dist/commands/exam.js
CHANGED
|
@@ -85,6 +85,8 @@ function printQuestion(q, answer) {
|
|
|
85
85
|
const answered = Object.keys(state?.answers || {}).length;
|
|
86
86
|
const help = getHelpState(state);
|
|
87
87
|
const eliminated = help.eliminated[q.number] || [];
|
|
88
|
+
// Top hint
|
|
89
|
+
console.log(chalk.gray(' Type "back" to pause · Don\'t type "exit" (it quits CLI)'));
|
|
88
90
|
// Progress bar
|
|
89
91
|
printQuestionProgress(q.number, total, answered);
|
|
90
92
|
// Easter egg
|
|
@@ -110,14 +112,15 @@ function printQuestion(q, answer) {
|
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
console.log();
|
|
113
|
-
//
|
|
115
|
+
// Bottom navigation
|
|
114
116
|
const remaining = help.max - help.used;
|
|
115
117
|
const helpHint = remaining > 0
|
|
116
118
|
? chalk.yellow('help') + chalk.gray(` (${remaining}/${help.max})`)
|
|
117
119
|
: (help.max < 8 ? chalk.gray('help 0/5 — type ') + chalk.yellow('more help') : chalk.gray('help 0/8'));
|
|
118
|
-
console.log(chalk.gray('
|
|
120
|
+
console.log(chalk.gray(' ') + chalk.white('A') + chalk.gray('/') + chalk.white('B') + chalk.gray('/') + chalk.white('C') + chalk.gray('/') + chalk.white('D') + chalk.gray(' to answer · ') + helpHint +
|
|
119
121
|
(q.number > 1 ? chalk.gray(' · ') + chalk.white('prev') : '') +
|
|
120
|
-
(q.number < total ? chalk.gray(' · ') + chalk.white('next') : '')
|
|
122
|
+
(q.number < total ? chalk.gray(' · ') + chalk.white('next') : '') +
|
|
123
|
+
chalk.gray(' · ') + chalk.white('back'));
|
|
121
124
|
}
|
|
122
125
|
export function registerExamCommand(program) {
|
|
123
126
|
const exam = program.command('exam').description('National selection exam');
|
package/dist/commands/lang.js
CHANGED
|
@@ -25,7 +25,7 @@ export function registerLangCommand(program) {
|
|
|
25
25
|
program
|
|
26
26
|
.command('lang [code]')
|
|
27
27
|
.description('Switch display language')
|
|
28
|
-
.action((code) => {
|
|
28
|
+
.action(async (code) => {
|
|
29
29
|
logCommand(`lang ${code || ''}`);
|
|
30
30
|
if (!code) {
|
|
31
31
|
const config = getConfig();
|
|
@@ -50,9 +50,25 @@ export function registerLangCommand(program) {
|
|
|
50
50
|
}
|
|
51
51
|
saveConfig({ language: code });
|
|
52
52
|
printSuccess(`Language set to: ${LANG_NAMES[code] || code}`);
|
|
53
|
-
// If exam in progress,
|
|
53
|
+
// If demo exam in progress, reload questions in new language
|
|
54
54
|
const state = getExamState();
|
|
55
|
-
if (state) {
|
|
55
|
+
if (state && state.session.examId === 'demo-free') {
|
|
56
|
+
try {
|
|
57
|
+
const { getLocalizedDemoQuestions, getLocalizedDemoSession } = await import('../lib/demo-exam.js');
|
|
58
|
+
state.questions = getLocalizedDemoQuestions();
|
|
59
|
+
state.session.examName = getLocalizedDemoSession().examName;
|
|
60
|
+
const { saveExamState } = await import('../lib/exam-state.js');
|
|
61
|
+
saveExamState(state);
|
|
62
|
+
const currentQ = state._lastQ || 1;
|
|
63
|
+
console.log();
|
|
64
|
+
console.log(chalk.green(` Demo questions reloaded in ${LANG_NAMES[code] || code}.`));
|
|
65
|
+
console.log(chalk.white(` Resuming: exam q ${currentQ}`));
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
console.log(chalk.gray(' Language changed. Resume with: exam q 1'));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if (state) {
|
|
56
72
|
const currentQ = state._lastQ || 1;
|
|
57
73
|
console.log();
|
|
58
74
|
console.log(chalk.gray(` Exam in progress — resuming Q${currentQ}:`));
|
package/dist/repl.js
CHANGED
|
@@ -318,6 +318,16 @@ export async function startRepl(program, resumeMode) {
|
|
|
318
318
|
logCommand(input);
|
|
319
319
|
// Exit — record, reset terminal colors, and quit
|
|
320
320
|
if (input === 'exit' || input === 'quit' || input === 'q') {
|
|
321
|
+
// During exam, warn and suggest back instead
|
|
322
|
+
if (getExamState()) {
|
|
323
|
+
console.log();
|
|
324
|
+
console.log(chalk.yellow(' ⚠ "exit" will close ICOA CLI entirely.'));
|
|
325
|
+
console.log(chalk.white(' To return to menu without quitting, type: ') + chalk.bold.cyan('back'));
|
|
326
|
+
console.log(chalk.gray(' Your exam progress is auto-saved.'));
|
|
327
|
+
console.log();
|
|
328
|
+
rl.prompt();
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
321
331
|
// stopLogSync();
|
|
322
332
|
recordExit();
|
|
323
333
|
console.log(chalk.gray(' Session saved. Use ') + chalk.white('icoa --resume') + chalk.gray(' to continue.'));
|
|
@@ -325,6 +335,21 @@ export async function startRepl(program, resumeMode) {
|
|
|
325
335
|
realExit(0);
|
|
326
336
|
return;
|
|
327
337
|
}
|
|
338
|
+
// "back" — return to main menu (clear exam state for demo, keep for real)
|
|
339
|
+
if (input === 'back') {
|
|
340
|
+
const state = getExamState();
|
|
341
|
+
if (state) {
|
|
342
|
+
console.log();
|
|
343
|
+
console.log(chalk.gray(' Exam paused. Your progress is saved.'));
|
|
344
|
+
console.log(chalk.white(' Resume: exam q 1') + chalk.gray(' · ') + chalk.white('exam review') + chalk.gray(' · ') + chalk.white('exam submit'));
|
|
345
|
+
console.log();
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
console.log(chalk.gray(' Already at main menu.'));
|
|
349
|
+
}
|
|
350
|
+
rl.prompt();
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
328
353
|
// Help — during exam, route to exam help; otherwise show REPL help
|
|
329
354
|
if (input === 'help' || input === '?') {
|
|
330
355
|
if (getExamState()) {
|