MCPcopy Create free account
hub / github.com/VirtualHotBar/NetMount / parseExtraCliArgs

Function parseExtraCliArgs

src/utils/cliArgs.ts:1–67  ·  view source on GitHub ↗
(input?: string)

Source from the content-addressed store, hash-verified

1function parseExtraCliArgs(input?: string): string[] {
2 if (!input || !input.trim()) return []
3
4 const args: string[] = []
5 let current = ''
6 let quote: '"' | "'" | null = null
7
8 for (let i = 0; i < input.length; i++) {
9 const ch = input[i]!
10 const next = input[i + 1]
11
12 if (ch === '\\') {
13 if (quote === '"') {
14 // In double quotes, allow escaping quote/backslash.
15 if (next === '"' || next === '\\') {
16 current += next
17 i++
18 continue
19 }
20 current += ch
21 continue
22 }
23
24 if (!quote) {
25 // Outside quotes, only treat as escape for whitespace/quote/backslash.
26 if (next && (/\s/.test(next) || next === '"' || next === "'" || next === '\\')) {
27 current += next
28 i++
29 continue
30 }
31 // Keep normal Windows paths like C:\temp\logs literally.
32 current += ch
33 continue
34 }
35 }
36
37 if (quote) {
38 if (ch === quote) {
39 quote = null
40 } else {
41 current += ch
42 }
43 continue
44 }
45
46 if (ch === '"' || ch === "'") {
47 quote = ch
48 continue
49 }
50
51 if (/\s/.test(ch)) {
52 if (current) {
53 args.push(current)
54 current = ''
55 }
56 continue
57 }
58
59 current += ch
60 }

Callers 2

startRcloneFunction · 0.90
startOpenlistFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected