Skip to content

docs: add util.parseArgs replacements for CLI argument parsers#274

Open
bjnewman wants to merge 4 commits intoe18e:mainfrom
bjnewman:feat/add-parseargs-replacements
Open

docs: add util.parseArgs replacements for CLI argument parsers#274
bjnewman wants to merge 4 commits intoe18e:mainfrom
bjnewman:feat/add-parseargs-replacements

Conversation

@bjnewman
Copy link
Copy Markdown

Summary

Adds migration documentation for replacing CLI argument parsing packages with Node.js built-in util.parseArgs (available in Node 18.3+/16.17+).

Packages covered

  • minimist
  • mri
  • arg
  • meow
  • yargs-parser
  • yargs
  • commander
  • sade

Changes

  • New docs/modules/parseargs.md with migration examples for each package
  • Added 8 entries to manifests/preferred.json

Notes

  • Examples use nullish coalescing (??) for defaults instead of parseArgs's default option to ensure compatibility with all Node 18.3+ versions
  • Includes feature comparison table and caveats about subcommands/auto-help
  • Covers advanced patterns like token-based parsing for minimist compatibility

@ljharb
Copy link
Copy Markdown

ljharb commented Jan 22, 2026

Also worth suggesting as an alternative is https://npmgraph.js.org/?q=pargs, which is built on top of util.parseArgs, has no deps, is written in ESM, and adds a number of helpful features when migrating from the listed packages.

@43081j
Copy link
Copy Markdown
Contributor

43081j commented Feb 8, 2026

sorry its taken me a while to get to this

i think we need some 2nd opinions here as this diverges from the usual structure we have

we follow one of two paths so far:

  • the document is named after the thing being replaced, and lists migrations to the various options
  • the document is named after the primary replacement (e.g. fetch), and lists other options but usually no migrations

in this case, it is listing the things being replaced along with their migrations. which is different to all other docs

@Fuzzyma thoughts?

@Fuzzyma
Copy link
Copy Markdown
Collaborator

Fuzzyma commented Feb 8, 2026

hm, so would you rather have x documents that all have one migration "x to fetch" and then in the fetch document link to all migrations? I think that would be cumbersome.

Is there a reason we usually dont have migrations in the "fetch-like" documents?

@bjnewman
Copy link
Copy Markdown
Author

bjnewman commented Feb 9, 2026

Thanks for the great work on this project and for taking the time to
review! I went with a single doc covering all 8 packages because their
APIs all converge on the same built-in replacement (util.parseArgs),
and I wanted to show the specific before/after for each since they have
pretty different APIs.

I was loosely modeling off of fetch.md, lodash-underscore.md, and
bluebird-q.md, which also group multiple packages into one doc. But I
can see how the per-package migration examples diverge from those.

Happy to restructure to better fit the project — just let me know what
you'd prefer and I'll update.

@43081j
Copy link
Copy Markdown
Contributor

43081j commented Feb 9, 2026

i more meant that the way fetch.md is structured is fine, but this isn't structured like that

im finding it difficult to find the right words to explain this 😂

the fetch document explains fetch and alternative packages.

this document explains packages being replaced.

i.e. the focus/context in the fetch doc is the alternatives, but the focus in this one is the replaced modules.

EDIT:

like the title of the page is # Replacements for argument parsers, but then we list the packages being replaced (the headings are those of the packages being replaced). everywhere else, we list the replacements (as per the title)

@gameroman

This comment was marked as resolved.

@gameroman
Copy link
Copy Markdown
Contributor

@bjnewman would you like to continue with this or prefer me to take over?

@43081j
Copy link
Copy Markdown
Contributor

43081j commented Mar 13, 2026

i think its fine to have one doc here, as we do that for some other packages (e.g. fetch-like packages).

but the headings need to be the things we're replacing these modules with.

currently this PR has this structure:

# Replacements for argument parsers

...

## minimist

...

but that doesn't make sense because minimist isn't a replacement for an argument parser. it is the thing being replaced.

it needs to be a much simpler doc i think, following the same pattern as all other docs:

# Replacements for argument parsers

## `util.parseArgs` (native, Node.js)

...

@gameroman

This comment was marked as resolved.

@gameroman
Copy link
Copy Markdown
Contributor

gameroman commented Mar 15, 2026

I still think we should have a separate doc for each, like we have for glob packages, as some packages have very different behaviours

And for packages that have similar behaviour we can combine into one

@bjnewman bjnewman force-pushed the feat/add-parseargs-replacements branch from 0482b28 to 7147eee Compare March 15, 2026 02:51
@bjnewman
Copy link
Copy Markdown
Author

Sorry for the delay in responding to the feedback. I updated the doc page to follow the patterns from the rest of the pages.

@gameroman if you want to separately open a PR with a single page for each of the targeted replacements please feel free I won't be offended.

gameroman

This comment was marked as resolved.

@gameroman
Copy link
Copy Markdown
Contributor

Sorry for the delay in responding to the feedback. I updated the doc page to follow the patterns from the rest of the pages.

No worries, thank you very much for contributing!

@bjnewman bjnewman force-pushed the feat/add-parseargs-replacements branch from 7147eee to c5d5762 Compare March 15, 2026 03:05
43081j
43081j previously approved these changes Mar 15, 2026
@Dustin4444
Copy link
Copy Markdown

Added one comment. Everything else looks fine

@43081j
Copy link
Copy Markdown
Contributor

43081j commented Apr 2, 2026

i think we need to rework this a bit. these packages parse args and generate help text:

  • meow
  • sade
  • commander
  • yargs

this means they can't really be replaced by parseArgs alone as much of their functionality exists for generating help text and what not.

i think we should mark those (minus sade) as replaceable by sade, stricli, and cleye.

@ghostdevv
Copy link
Copy Markdown
Collaborator

ghostdevv commented Apr 5, 2026

i think we should mark those (minus sade) as replaceable by sade, stricli, and cleye.

cac also? what about frameworks that do more, there is that one that I can't remember the name of, but I guess it's a job of communicating what you should use based on what you need...

@43081j
Copy link
Copy Markdown
Contributor

43081j commented Apr 5, 2026

i'd basically expect we end up with 3 categories/sets of replacements:

  • Argument parsers (mri, arg, etc. -> parseArgs)
  • CLI builders (meow, commander, yargs, etc. -> sade, cleye, stricli)
  • CLI renderers (inquirer, etc. -> clack)

and any that do a bit of everything should really be documented as being replaced by a builder + renderer rather than a catch all package somehow.

@gameroman
Copy link
Copy Markdown
Contributor

Also getopts

@gameroman
Copy link
Copy Markdown
Contributor

I will also make a pr 👍

@43081j 43081j requested a review from ghostdevv April 12, 2026 17:44
@43081j
Copy link
Copy Markdown
Contributor

43081j commented Apr 12, 2026

@ghostdevv i've reworked this to only have the option parsers, and added mri as a replacement choice too (for anyone who doesn't have new enough Node for parseArgs)

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.

8 participants