@hammerhq/hargs
v2.3.0
Published
✨ A simple argument parsing system with 0 dependencies
Downloads
15
Maintainers
Readme
@hammerhq/hargs
✨ A simple argument parsing system with 0 dependencies
- A friendly fork of vercel/arg
📦 Installation
$ npm install @hammerhq/hargs
🚀 Usage
hargs(IOptionDefinition, argv?);
IOptionDefinition
: Where options are defined to be used when separating arguments. Structure:
{
// Option definitions
"--option": String,
"--option2": Boolean,
"--option3": MyCustomFunction,
// Aliases
"-o": "--option",
}
argv?
: Arguments to parse. Default isprocess.argv.slice(2)
(string[]
).
🛠️ Example
/* es6 */
import { hargs } from "@hammerhq/hargs";
/* commonJS */
const { hargs } = require("@hammerhq/hargs");
const argv = ["--foo=bar", "-p", "2", "--foo", "baz", "test", "1", "2", "-h"];
hargs(
{
"--help": Boolean,
"--page": Number,
"--foo": [String],
"-p": "--page",
"-h": "--help",
},
argv,
);
/*
{
_unknown: [ 'test', '1', '2' ],
'--foo': [ 'bar', 'baz' ],
'--page': 2,
'--help': false
}
*/
🧦 Looking For Contributors
We are looking for contributors to actively work on Hammer and to contribute to the repos. There is still lots of work to do. If you are interested in contributing, please join our Discord server. (There will be a surprise for early contributors!)
🔑 License
Copyright © 2023 Barış DEMİRCİ.
Distributed under the GPL-3.0 License. See LICENSE
for more information.
🧦 Contributing
This repo is open for #hacktoberfest. Feel free to use GitHub's features.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/my-feature
) - Run prettier (
npm run format
) - Commit your Changes (
git commit -m 'my awesome feature my-feature'
) - Push to the Branch (
git push origin feature/my-feature
) - Open a Pull Request
⭐️ Show your support
Give a ⭐️ if this project helped you!
☎️ Contact
- Mail: [email protected]
- Discord: https://338.rocks/discord
- Website: https://hammer.338.rocks
- Documentation: https://hammer.338.rocks/docs/packages/hargs