MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / parseArguments

Function parseArguments

src/utils/prefixParser.js:32–76  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

30}
31
32function parseArguments(input) {
33 const args = [];
34 let current = '';
35 let inQuote = false;
36 let quoteChar = '';
37
38 for (let i = 0; i < input.length; i++) {
39 const char = input[i];
40
41 if (inQuote) {
42 if (char === quoteChar) {
43
44 inQuote = false;
45 args.push(current);
46 current = '';
47 } else {
48 current += char;
49 }
50 } else {
51 if (char === '"' || char === "'") {
52
53 if (current.trim()) {
54 args.push(current.trim());
55 current = '';
56 }
57 inQuote = true;
58 quoteChar = char;
59 } else if (char === ' ') {
60
61 if (current.trim()) {
62 args.push(current.trim());
63 current = '';
64 }
65 } else {
66 current += char;
67 }
68 }
69 }
70
71 if (current.trim()) {
72 args.push(current.trim());
73 }
74
75 return args;
76}
77
78export function mapArgumentsToOptions(args, commandData) {
79 const options = {};

Callers 1

parsePrefixCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected