Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697import { type ArgvSpec, parseArgv,} from './argv.ts';
//region Push post-subcommand region parser
/** Declared option surface of the post-`push` argv region. Models the user-toggled atomicity flags so the wrapper can inject `--atomic` only when the caller has not chosen explicitly. Pathspecs and other tokens are captured generically; the wrapper does not transform them. */const pushRegionSpec: ArgvSpec = { flags: { atomicFlags: { names: [ '--atomic', '--no-atomic', ], }, dryRunFlags: { names: [ '-n', '--dry-run', ], }, noDryRunFlags: { names: ['--no-dry-run',], }, }, valueOptions: {},};
//endregion Push post-subcommand region parser
//region Push region facts
/** Facts about the post-`push` argv region used by atomic-push policy. */export type PushRegion = { /** True when caller has chosen atomic or non-atomic mode explicitly. */ readonly hasAtomicChoice: boolean; /** Whether final exact dry-run toggle requests no remote update. */ readonly isDryRun: boolean;};
/** Parses the post-`push` argv region into a structured fact set used by the atomic-push rule. The rule only needs to know whether the caller already made an explicit choice between atomic and non-atomic. @param postSubcommandArgs - Arguments strictly after `push` subcommand. @returns Fact record consumed by atomic-push policy. @example ```ts parsePushRegion(['origin', 'main']).hasAtomicChoice; // => false (no explicit choice; wrapper will inject --atomic) ``` */export function parsePushRegion( postSubcommandArgs: readonly string[],): PushRegion { /** Parsed facts over the post-subcommand region. */ const { flagCounts, } = parseArgv({ args: postSubcommandArgs, spec: pushRegionSpec, },); /** Final exact dry-run toggle, matching Git's last-option-wins behavior. */ const isDryRun = postSubcommandArgs.reduce( function applyDryRunToggle( enabled, arg, ) { if ((arg === '-n') || (arg === '--dry-run')) return true; if (arg === '--no-dry-run') return false; return enabled; }, false, ); return { hasAtomicChoice: (flagCounts.atomicFlags ?? 0) > 0, isDryRun, };}
//endregion Push region facts