MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / parseCommand

Function parseCommand

src/workspaces/config.ts:140–161  ·  view source on GitHub ↗
(raw: string | undefined)

Source from the content-addressed store, hash-verified

138}
139
140function parseCommand(raw: string | undefined): readonly string[] {
141 if (raw && raw.trim().length > 0) {
142 const trimmed = raw.trim();
143 if (trimmed.startsWith('[')) {
144 try {
145 const parsed: unknown = JSON.parse(trimmed);
146 if (
147 Array.isArray(parsed) &&
148 parsed.every((v): v is string => typeof v === 'string') &&
149 parsed.length > 0
150 ) {
151 return parsed;
152 }
153 } catch {
154 // fall through to whitespace split
155 }
156 }
157 const parts = trimmed.split(/\s+/);
158 if (parts.length > 0 && parts[0]) return parts;
159 }
160 return ['claude'];
161}
162
163function parseIntEnv(raw: string | undefined, fallback: number, lo: number, hi: number): number {
164 if (raw === undefined) return fallback;

Callers 1

loadConfigFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected