MCPcopy Create free account
hub / github.com/coleam00/remote-agentic-coding-system / parseCommand

Function parseCommand

src/handlers/command-handler.ts:50–68  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

48}
49
50export function parseCommand(text: string): { command: string; args: string[] } {
51 // Match quoted strings or non-whitespace sequences
52 const matches = text.match(/"[^"]+"|'[^']+'|\S+/g) || [];
53
54 if (matches.length === 0 || !matches[0]) {
55 return { command: '', args: [] };
56 }
57
58 const command = matches[0].substring(1); // Remove leading '/'
59 const args = matches.slice(1).map(arg => {
60 // Remove surrounding quotes if present
61 if ((arg.startsWith('"') && arg.endsWith('"')) || (arg.startsWith("'") && arg.endsWith("'"))) {
62 return arg.slice(1, -1);
63 }
64 return arg;
65 });
66
67 return { command, args };
68}
69
70export async function handleCommand(
71 conversation: Conversation,

Callers 2

handleCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected