Files
delta-backup/lib/args.js
mikael-lovqvists-claude-agent 33bd288f9e Initial project outline
- package.json (ESM, bin entry)
- bin/delta-backup.js — entrypoint
- lib/args.js — CLI arg parsing via Node parseArgs
- lib/config.js — config file merging + required path guards
- lib/spawn.js — safe process spawning (no shell strings)
- lib/state.js — sequence number + phase state management
- lib/backends/zstd.js — zstd delta backend
- lib/backends/index.js — backend registry
- lib/commands/run.js — full run skeleton (phases 1-3 wired, 4-6 stubbed)
- lib/commands/status.js — status command
2026-03-07 01:05:46 +00:00

54 lines
1.5 KiB
JavaScript

/**
* CLI argument parsing — no external deps, uses Node's parseArgs.
*/
import { parseArgs as nodeParseArgs } from 'util';
const HELP = `
Usage: delta-backup [options] <command>
Commands:
run Full backup run (clear PEND, rsync, delta, commit, promote)
status Show current state
Options:
--source <path> SOURCE directory (required)
--prev <path> PREV directory (required)
--pend <path> PEND directory (required)
--deltas <path> DELTAS directory (required)
--backend <name> Delta backend: zstd (default), xdelta3
--config <file> Load options from JSON config file (flags override)
--dry-run Print what would happen, execute nothing
--help Show this help
`.trim();
export function parseArgs(argv) {
const { values, positionals } = nodeParseArgs({
args: argv,
options: {
source: { type: 'string' },
prev: { type: 'string' },
pend: { type: 'string' },
deltas: { type: 'string' },
backend: { type: 'string' },
config: { type: 'string' },
'dry-run': { type: 'boolean', default: false },
help: { type: 'boolean', default: false },
},
allowPositionals: true,
});
if (values.help) {
console.log(HELP);
process.exit(0);
}
const command = positionals[0];
if (!command) {
console.error('Error: command required (run, status)\n');
console.error(HELP);
process.exit(1);
}
return { ...values, command, dryRun: values['dry-run'] };
}