aahrgs
is a simple JavaScript library for parsing command-line arguments. It processes an array of command-line arguments and returns an object where the keys are the argument names (without leading dashes) and the values are either true
(for flags) or the argument values.
You can install aahrgs
using npm:
npm install aahrgs
Here's an example of how to use aahrgs
in your project:
const aahrgs = require('aahrgs');
const argv = process.argv.slice(2);
const args = aahrgs(argv);
console.log(args);
If you run the above script with the following command:
node script.js --name John -a 25 --verbose
The output will be:
{
"name": "John",
"a": "25",
"verbose": true
}
You can also pass an array of arguments directly to the function:
const aahrgs = require('aahrgs');
const args = aahrgs(['--name', 'John', '-a', '25', '--verbose']);
console.log(args);
The output will be the same:
{
"name": "John",
"a": "25",
"verbose": true
}
Parses command-line arguments.
argv
(Array of strings): The array of command-line arguments.
Object
: The parsed arguments as key-value pairs.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any changes.
For any questions or suggestions, please open an issue on the GitHub repository.