Skip to content

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

Open
bjnewman wants to merge 1 commit intoes-tooling:mainfrom
bjnewman:feat/add-parseargs-replacements
Open

docs: add util.parseArgs replacements for CLI argument parsers#274
bjnewman wants to merge 1 commit intoes-tooling:mainfrom
bjnewman:feat/add-parseargs-replacements

Conversation

@bjnewman
Copy link

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

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
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
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
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
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
Contributor

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

@43081j
Copy link
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
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
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
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
"replacements": ["fs.rm", "fs.rmdir", "premove"],
"url": {"type": "e18e", "id": "rimraf"}
},
"sade": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure sade should be in here.

From what I remember it uses mri under the hood to do arguments parsing. But it exists to provide help text etc on top of that.

In a future pr, we should probably add sade as a replacement itself for some packages in fact

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does use mri, yes

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.

5 participants