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

3 biodiscus 6 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 (6)

FerkiHN · 16h 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 · 13h 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.

FerkiHN · 4h ago
If you want more ideas, I don't know how I came up with them, but you can think about them:

Contextual Flags: Automatically activate flags based on context (e.g., URL, time of day, user-agent). Why: Users get adaptive flags without manual checks.

Flag Usage Statistics: Log flag activation events for analysis. Why: Users see which flags are popular without complex integrations. Shadow Flags (for A/B testing): A flag that quietly activates for a subset of users (e.g., 10% of traffic). Why: Out-of-the-box A/B tests without external systems.

Flag Groups: Allow grouping flags (e.g., "UI") and managing an entire group with one command. Why: Simplifies management of related flags. Automatic DOM Updat: Automatically update DOM elements with a special attribute when a flag changes. Why: Zero UI integration; users add a data-flag attribute, the library does the rest.

FerkiHN · 4h ago
I'm glad some of my tips were useful, and I understand that you are making minimalist libraries, I also like to keep everything minimal and optimized.

By the way, if you can, please help me promote my repository. I've also been doing different things and my project is of course not ready yet, but could you please put a star on my repository?

https://github.com/Ferki-git-creator/phono-in-terminal-image...

biodiscus · 1h ago
Thanks for sharing your PIT repo, I starred it!

It would be great to have an option to save the ASCII output to a file, e.g.:

--output, -o <file>

FerkiHN · 1h ago
I love the NN community, I don't know what I would do without you.

You are the best, it motivates me to improve further PIT.