/** * Parses a command line into invocations * * Answers one question: which programs the command runs and with what * arguments. Callers decide what to do with the finding — this module only * parses the string, with no calls to the server. */ /** One program invocation within a simple command segment */ export interface Invocation { /** Name without the path: `/sbin/reboot` and `reboot` are the same */ name: string; /** Arguments as written, quotes included */ args: string[]; } /** Strip the quotes an argument may be wrapped in entirely */ export declare function unquote(argument: string): string; /** * Split the command into simple segments. * * Shell separators (`;`, `&&`, `||`, `|`, newline) split commands only * outside quotes: `git commit -m "fix; reboot handler"` is one command, and * splitting on the semicolon would leave `reboot` in the command position. */ export declare function splitSegments(command: string): string[]; /** Split a segment into words without breaking quoted chunks */ export declare function tokenize(segment: string): string[]; /** * Find program invocations across the whole command. * * A word in the command position is an invocation; the same word in an * argument, a path, or a quoted string is not. */ export declare function parseInvocations(command: string): Invocation[];