Show HN: Flaget – small 5kB CLI argument parser for Node.js

3 biodiscus 2 7/5/2025, 6:48:27 PM
A lightweight (5 kB) alternative to yargs-parser (85 kB). Supports all standard flag formats. https://github.com/webdiscus/flaget

Comments (2)

FerkiHN · 8h ago
Bro, cool program, I wish you good luck in further development, I gave you a star on GitHub, I hope there will be more of them, and by the way, here are the improvements I found:

1. Strict typing & validation — support ranges, regex, custom types (dates, emails).

2. Better error messages — clear feedback on invalid args.

3. Auto-generated help — built-in --help with descriptions and examples.

4. Advanced aliases — support multiple aliases and priority handling.

5. Nested options — parse flags like --db.host into objects.

6. Async validators & transformers — for things like file existence checks.

7. Config file support — load defaults from JSON/YAML files.

8. Named positional args — support and validate ordered params.

9. Localization (i18n) — multi-language error/help messages.

10. Performance optimization — handle large numbers of args fast.

11. Test integration — utilities for easy CLI testing with frameworks.

biodiscus · 6h ago
Thanks for the * and your cool suggestions!

There are already big "do-it-all" CLI libraries like "yargs-parser" (85 kB), "meow" (419 kB), "minimist" (55kB), etc.

Flaget is intentionally minimal — small size is the killer feature. I want to keep it as compact as possible without bloating it with rarely needed functionality.

The e18e community focuses on optimising npm packages by replacing heavy dependencies with smaller alternatives.

Still, some of your ideas are very useful, and I may add:

- Named positional

- Nested options

But others are outside the scope of a small library like this.