matthewwong525/WongStack / .agents/plugins/memory
memory
Verifiedscripts/lib/cli.mjs
View on GitHub// One CLI convention for every WongStack script: `--help` exits 0; a usage error or unknown flag exits 2.
// Skills import it by path, like primary-root.mjs; scripts/lib-cli.mjs re-exports it for the pack.
import { realpathSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { parseArgs } from 'node:util';
/** True when the module at `url` is the script node was started with, even through a symlink. */
export function isMain(url) {
try {
return Boolean(process.argv[1]) && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(url));
} catch {
return false;
}
}
/** Print a usage error and exit 2. */
export function usageError(usage, message) {
console.error(message ? `${message}\n${usage}` : usage);
process.exit(2);
}
/** Strict `parseArgs` with `--help`. Returns `{ values, positionals }`. */
export function parseCli({ usage, options = {}, allowPositionals = false, args = process.argv.slice(2) }) {
let parsed;
try {
parsed = parseArgs({ args, options: { ...options, help: { type: 'boolean' } }, allowPositionals, strict: true });
} catch (error) {
usageError(usage, error.message);
}
if (parsed.values.help) {
console.log(usage);
process.exit(0);
}
return parsed;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |