INNER CODE UNIT · TypeScript

parse

rit3zh/reacticx · cloudflare/cli/index.ts:114

function parse(argv: readonly string[]): { command: Command; flags: Flags } {
  const separator = argv.indexOf("--");
  const own = separator === -1 ? [...argv] : argv.slice(0, separator);
  const passthrough = separator === -1 ? [] : argv.slice(separator + 1);

  const first = own[0];
  const command = (COMMANDS as string[]).includes(first ?? "")
    ? (first as Command)
    : ("push" as Command);

  const has = (...names: string[]) => names.some((name) => own.includes(name));

  return {
    command,
    flags: {
      dry: has("--dry", "--dry-run", "-n"),
      check: has("--check"),
      force: has("--force", "-f"),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…