"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
let src_external_shell_quote = require("../external/shell-quote");

//#region src/argv/parse-args-string.ts
/**
* @file Tokenize a shell-style command string into an argv array. Delegates to
*   the vendored `shell-quote` parser and flattens its output to bare-string
*   tokens — operators (`&&`, `|`, `;`, …), comments (`# …`), and glob tokens
*   are dropped, leaving only the words a `child_process.spawn` /
*   `execFileSync` call would receive. Unlike `shell/parse` (which preserves
*   that structure), this is purpose-built for "turn a command string into
*   argv". Single + double quotes, backslash escapes, and `key="value"` mixed
*   tokens are honored per POSIX `sh`; `$VAR` references collapse to an empty
*   string (shell-quote resolves them against an env, and none is supplied
*   here). Common use case: turning a `string` representation of a command
*   (e.g. from a config file, a `bin` field, or a shellout test fixture) into
*   an argv array that `execFileSync` / `child_process.spawn` accepts directly
*   — bypassing the platform shell + its quoting differences (`cmd.exe` vs
*   `bash`).
*/
/**
* Tokenize a shell-style command string into argv. Single + double quote pairs
* are recognized and stripped; whitespace outside quotes separates tokens.
* Operators and comments are dropped (use `shell/parse` to keep them).
*
* @example
*   parseArgsString('git commit -m "hello world"')
*   // → ['git', 'commit', '-m', 'hello world']
*
*   parseArgsString('foo --bar="x y" baz')
*   // → ['foo', '--bar=x y', 'baz']
*
*   parseArgsString("echo 'one two' three")
*   // → ['echo', 'one two', 'three']
*/
function parseArgsString(cmd) {
	const argv = [];
	for (const entry of (0, src_external_shell_quote.parse)(cmd)) if (typeof entry === "string") argv.push(entry);
	return argv;
}

//#endregion
exports.parseArgsString = parseArgsString;