🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

getarg

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

getarg

Quick CLI argv parser and validator

0.0.5
latest
Source
npm
Version published
Weekly downloads
5.9K
20.67%
Maintainers
1
Weekly downloads
 
Created
Source

Simple and fast CLI args parser for Node

Install

npm i getarg

Basic usage:

import getArgs from 'getarg';

//Run without any options to get an object of all args supplied at runtime
const args = getArgs({
    file:{
        required: true,
        type: "string",
        help: "A helpful message",
        requires: ['output'] //dependent parameters
        alias: "f"
    }
    output:{
        help: "Another helpful message",
        required: true,
        type: "string", //supported: number/json/any
        alias: "o",
    }
},{
    usage: "Usage: myapp.js <command>" //customize help header
});

console.log(args);

Example Run

> node cli.js -f ./file.js --output=./out.js

{
    file: "./file.js",
    output: "./out.js"
}

Example Info/Error:

> node cli.js --file

[!] The paramater '--file' is not a string.

Usage: myapp.js <command>

--file/-f [required]              Another helpful message   

--output/-o [required]            A helpful message

Keywords

darg

FAQs

Package last updated on 26 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts