argv Utils
The argv-utils
package is a lightweight library for Node.js that simplifies working with command-line arguments passed to your scripts. It streamlines the process of accessing and managing arguments from process.argv
property.
Getting Started
Install the package:
npm install -D argv-utils
Usage
node my-script.js --one --two="Hello World!" --someValue="false"
import { argv } from 'node:process';
import { parseArgs } from 'argv-utils';
parseArgs(argv);
Types
interface IBaseParsedArgs {
execPath: string,
scriptPath: string,
}
interface IParsedArgs extends IBaseParsedArgs {
[argKey: string]: string
}
If you wish to enforce strong typing in your script, extend the base type as follows:
interface IMyScriptArgs extends IBaseParsedArgs {
src?: string,
init?: 'true',
development?: 'true',
staging?: 'true',
production?: 'true',
}
Built With
Running the Tests
npm run test:unit
License
MIT
Deployment
Install dependencies:
npm install
Build the library:
npm start
Publish to npm
:
npm publish