wispy-cli 2.7.3 → 2.7.4
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/lib/commands/ws.mjs
CHANGED
|
@@ -1,58 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
* lib/commands/ws.mjs — Final Workstream CLI commands
|
|
3
|
-
*/
|
|
1
|
+
import { select } from '@inquirer/prompts';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
export async function handleWsCommand() {
|
|
4
|
+
try {
|
|
5
|
+
const action = await select({
|
|
6
|
+
message: 'What WebSocket action would you like to perform?',
|
|
7
|
+
choices: [
|
|
8
|
+
{ name: 'Start WebSocket Client', value: 'startClient' },
|
|
9
|
+
{ name: 'Run WebSocket Server Debug Mode', value: 'runServerDebug' },
|
|
10
|
+
{ name: 'Exit', value: 'exit' }
|
|
11
|
+
]
|
|
12
|
+
});
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Validate subcommands and arguments for `wispy ws`
|
|
30
|
-
*/
|
|
31
|
-
function validateWsArgs(args) {
|
|
32
|
-
if (!args.length) return null; // No args => List workstreams
|
|
33
|
-
const cmd = args[0];
|
|
34
|
-
if (!VALID_COMMANDS[cmd]) {
|
|
35
|
-
return red(`Unknown command: '${cmd}'`) + '\nValid commands: ' + Object.keys(VALID_COMMANDS).join(', ');
|
|
36
|
-
}
|
|
37
|
-
const expectedArgs = VALID_COMMANDS[cmd].args;
|
|
38
|
-
if (args.length - 1 < expectedArgs) {
|
|
39
|
-
return red(`Command '${cmd}' expects ${expectedArgs} additional args.`);
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export async function handleWsCommand(args) {
|
|
45
|
-
const validationError = validateWsArgs(args);
|
|
46
|
-
if (validationError) {
|
|
47
|
-
console.error(validationError);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!args.length) {
|
|
52
|
-
console.log("Listing workstreams...");
|
|
53
|
-
return; // Implement listing logic.
|
|
14
|
+
switch (action) {
|
|
15
|
+
case 'startClient':
|
|
16
|
+
console.log('Starting WebSocket client...');
|
|
17
|
+
break;
|
|
18
|
+
case 'runServerDebug':
|
|
19
|
+
console.log('Running server in debug mode...');
|
|
20
|
+
break;
|
|
21
|
+
case 'exit':
|
|
22
|
+
console.log('Exiting WebSocket command.');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
} catch (err) {
|
|
26
|
+
if (err.name === 'ExitPromptError') {
|
|
27
|
+
console.log('Prompt closed. Exiting command gracefully.');
|
|
28
|
+
} else {
|
|
29
|
+
console.error('Unexpected error:', err);
|
|
30
|
+
}
|
|
54
31
|
}
|
|
55
|
-
|
|
56
|
-
const cmd = args[0];
|
|
57
|
-
console.log(`Executing command: ${cmd}`);
|
|
58
32
|
}
|