Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

<1kB CLI flag parser

License

NotificationsYou must be signed in to change notification settings

bombshell-dev/args

Repository files navigation

A <1kB library for parsing CLI flags. Inspired by Deno'sstd/cliparseArgs module.

Features

🤏 very small

🍃 very simple

🏃 very fast (beatsnode:util)

🔏 strongly typed

Usage

Basic usage does not require any configuration.

import{parse}from"@bomb.sh/args";// my-cli build --bundle -rf --a value --b=value --c 1constargv=process.argv.slice(2);constargs=parse(argv);console.log(args);// { _: ['build'], bundle: true, r: true, f: true, a: "value", b: "value", c: 1 }

Parsing can be configured to ensure arguments are coerced to specific types, which enhances type safety.

constargs=parse(argv,{default:{a:1,b:2,c:"value"},alias:{h:"help"},boolean:["foo","bar"],string:["baz","qux"],array:["input"],});

Benchmarks

mri               x 1,650,986 ops/sec ±0.32% (97 runs sampled)@bomb.sh/args     x 1,407,191 ops/sec ±0.38% (99 runs sampled)minimist          x 383,506 ops/sec ±0.28% (99 runs sampled)node:util         x 320,953 ops/sec ±0.35% (98 runs sampled)yargs-parser      x 31,874 ops/sec ±1.32% (92 runs sampled)

Acknowledgements

This package was previously published asultraflag up untilv0.3.0, when it was renamed to@bomb.sh/args.


[8]ページ先頭

©2009-2025 Movatter.jp