-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add Args documentation #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
}, | ||
"dependencies": { | ||
"@astrojs/starlight": "^0.32.2", | ||
"@bomb.sh/args": "^0.3.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm do we need to install this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have to check, but I'm pretty sure that without it twoslash won't be able to do its magic. But maybe it can be moved into dev dependencies ? 🤔 |
||
"@clack/core": "^0.4.1", | ||
"@clack/prompts": "^0.10.0", | ||
"@types/node": "^22.13.11", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
title: Args | ||
description: Learn about the Args package and its capabilities | ||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
title: Getting Started | ||
description: Learn how to get started with Args | ||
--- | ||
|
||
import { Tabs, TabItem } from '@astrojs/starlight/components'; | ||
|
||
A <1kB library for parsing CLI flags. Inspired by Deno's `std/cli` [`parseArgs`](https://github.com/denoland/std/blob/main/cli/parse_args.ts) module. | ||
|
||
## Features | ||
|
||
🤏 very small | ||
|
||
🍃 very simple | ||
|
||
🏃 very fast (beats [`node:util`](https://nodejs.org/api/util.html#utilparseargsconfig)) | ||
|
||
🔏 strongly typed | ||
|
||
## Installation | ||
|
||
You can install Args using npm, yarn, or pnpm: | ||
|
||
<Tabs> | ||
<TabItem label="npm" icon="seti:npm"> | ||
```bash | ||
npm install @bomb.sh/args | ||
``` | ||
</TabItem> | ||
<TabItem label="pnpm" icon="pnpm"> | ||
```bash | ||
pnpm add @bomb.sh/args | ||
``` | ||
</TabItem> | ||
<TabItem label="Yarn" icon="seti:yarn"> | ||
```bash | ||
yarn add @bomb.sh/args | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
|
||
|
||
## Quick Start | ||
|
||
Basic usage does not require any configuration. | ||
|
||
```ts twoslash | ||
import { parse } from "@bomb.sh/args"; | ||
|
||
// my-cli build --bundle -rf --a value --b=value --c 1 | ||
const argv = process.argv.slice(2); | ||
const args = 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. | ||
|
||
```ts twoslash | ||
import { parse } from "@bomb.sh/args"; | ||
|
||
const args = parse(process.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 as `ultraflag` up until `v0.3.0`, when it was renamed to `@bomb.sh/args`. | ||
|
||
## Next Steps | ||
|
||
1. Check out our [Examples](/docs/args/guides/examples) for more practical use cases | ||
2. Learn about [Best Practices](/docs/args/guides/best-practices) for building CLIs | ||
3. Explore the [API Reference](/docs/args/api) for detailed documentation | ||
4. Join our [Discord community](https://bomb.sh/chat) for support and discussions | ||
|
||
## Contributing | ||
|
||
We welcome contributions! Please check out our [Contributing Guide](/contributing) for details on our code of conduct and the process for submitting pull requests. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
title: Best Practices | ||
description: Learn the best practices for using Args effectively | ||
--- | ||
|
||
This guide covers recommended practices and patterns for using Args effectively in your applications. | ||
|
||
## General Guidelines | ||
|
||
_TBD_ | ||
|
||
## Performance Considerations | ||
|
||
_TBD_ | ||
|
||
## Accessibility | ||
|
||
_TBD_ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: Examples | ||
description: Learn through practical examples of using Args | ||
--- | ||
|
||
This guide provides practical examples of using Args in different scenarios. | ||
|
||
## Basic Examples | ||
|
||
_TBD_ | ||
|
||
## Advanced Examples | ||
|
||
_TBD_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌