Initial commit: Nosterm client (terminal-style Nostr chat SPA)
ci / build (push) Successful in 1m3s
ci / image (push) Successful in 41s

This commit is contained in:
Robert Goodall
2026-07-24 13:47:53 -04:00
commit cd2b900639
147 changed files with 16504 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
/**
* tokenize a command argument string, honoring double and single quotes so
* args with spaces can come through as a single token.
*
* parse('set "Solarized Dark"') -> ['set', 'Solarized Dark']
*
* an unterminated quote just runs to end-of-input (lenient, so someone
* mid-typing never hits a hard error from the tokenizer itself).
*/
export function tokenize(input: string): string[] {
const tokens: string[] = [];
let current = '';
let quote: '"' | "'" | null = null;
let hasToken = false;
for (let i = 0; i < input.length; i++) {
const ch = input[i];
if (quote) {
if (ch === quote) {
quote = null;
} else {
current += ch;
}
continue;
}
if (ch === '"' || ch === "'") {
quote = ch;
hasToken = true;
continue;
}
if (ch === ' ' || ch === '\t') {
if (hasToken) {
tokens.push(current);
current = '';
hasToken = false;
}
continue;
}
current += ch;
hasToken = true;
}
if (hasToken) tokens.push(current);
return tokens;
}