toCommandLine
Converts an array of command-line arguments into a single command-line string using the CommandLineToArgvW convention (the standard used by the Microsoft C runtime and most Windows programs).
Implements the ArgvQuote algorithm from Everyone quotes command line arguments the wrong way: backslashes before quotes and at the end of a quoted argument are doubled.
This produces a shell-agnostic command line. Callers that route through a specific shell (cmd.exe, PowerShell, sh) must apply shell-specific escaping on top — see cmdEscapeCommandLine.
Import:
import { toCommandLine } from 'obsidian-dev-utils/script-utils/cli-utils';Signature:
function toCommandLine(args: string[]): stringParameters:
| Parameter | Type | Description |
|---|---|---|
args | string[] | The array of command-line arguments to convert. |
Returns: string — A string representing the command-line invocation.
Links to this page: