INNER CODE UNIT · TypeScript

getLongOptionName

EndBug/add-and-commit · src/util.ts:268

function getLongOptionName(arg: string): string | undefined {
  if (!arg.startsWith('--') || arg === '--') return undefined;
  const body = arg.slice(2);
  const eq = body.indexOf('=');
  return (eq === -1 ? body : body.slice(0, eq)).toLowerCase();
}

function matchesLongOptionPrefix(
  arg: string,
  options: ReadonlyArray<{canonical: string; minPrefix: string}>,
): boolean {
  const name = getLongOptionName(arg);
  if (!name) return false;
  return options.some(
    ({canonical, minPrefix}) =>
      name.length >= minPrefix.length && canonical.startsWith(name),
  );
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…