Skip to content

feat(cli) add input dedup, --no-cache flag, and subcommand fallback#26

Merged
indexzero merged 1 commit intomainfrom
adhoc
Mar 10, 2026
Merged

feat(cli) add input dedup, --no-cache flag, and subcommand fallback#26
indexzero merged 1 commit intomainfrom
adhoc

Conversation

@indexzero
Copy link
Owner

@indexzero indexzero commented Mar 9, 2026

What

Adds a uniqueNames() helper to cli/cli/src/cmd/packument/fetch-list.js that deduplicates package names parsed from JSON and text input files, handling both plain string entries and {name, ...} objects. The existing --no-cache CLI flag is wired through to the packument client by constructing requestOptions from cli.values.cache. importCommand in cli/cli/src/index.js is refactored to gracefully handle invocations without a subcommand — it first attempts to load a command-level index.js module before falling back to an informative usage error.

Why

Input deduplication

loadPackageNames previously returned raw items verbatim, so duplicate entries in an input file caused redundant fetches. JSON inputs could also contain {name: "..."} objects instead of bare strings, which would silently pass through as non-string values. uniqueNames() normalizes both shapes, warns on unrecognized entries, and deduplicates via a Set.

--no-cache passthrough

The --no-cache flag was accepted by the argument parser but never forwarded to client.request(). The new requestOptions object conditionally sets { cache: false } when the flag is present, so cache-busting actually takes effect.

Subcommand fallback

importCommand previously required both a command and subcommand, throwing an opaque import error when only a top-level command was given. The refactored version tries ./cmd/${cmd}/index.js first and, if no index module exists, prints a clear "no subcommand provided" message with CLI usage before exiting.

Risk Assessment

Low risk: All changes are additive. The dedup helper is a pure function. The --no-cache wiring only activates when the flag is explicitly passed. The importCommand refactor preserves the existing two-argument path unchanged and only adds a new fallback branch.

Add `uniqueNames()` to `fetch-list.js` to deduplicate package names
from JSON and text inputs, handling both plain strings and `{name}`
objects. Wire up the existing `--no-cache` CLI flag to actually pass
`{ cache: false }` through to the packument client.

Refactor `importCommand` in `index.js` to gracefully handle missing
subcommands by attempting to load the command's `index.js` module
before falling back to a usage error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@indexzero indexzero merged commit 81ce0dd into main Mar 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant