Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@benev/argv

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@benev/argv

command line argument parser

  • 0.0.0-dev.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
147
decreased by-33.78%
Maintainers
1
Weekly downloads
 
Created
Source

🎛️ @benev/argv

command line argument parser

🤖 for making node cli programs
🕵️‍♂️ designed for proper typescript typings
🏗️ experimental design, breaking changes likely
🧼 zero dependencies
💖 made free and open source, just for you


argv instructions

  1. install via npm
    npm install @benev/argv
    
  2. import the cli function
    import {parse} from "@benev/argv"
    
  3. specify your params and options fields for parsing
    const {args, params} = parse({
    
      // process.argv is a nodejs builtin
      argv: process.argv,
    
      // positional arguments your program will accept
      argorder: ["mode", "amount"],
    
      // define which type of parsing to use for each argument
      args: {
        mode: String,
        amount: Number,
      },
    
      // options your program will accept
      params: {
        "--label": String,
        "--port": Number,
        "--importmap": String,
        "--verbose": Boolean,
      },
    })
    
  4. now you can access your args and params
    // example command:
    //   main.js coolmode --verbose true --port 8021
    
    args.mode
      // "coolmode"
    
    params["--verbose"]
      // true
    
    params["--port"]
      // 8021
    

notes

  • argv is very simple. it just parses the args and params.
  • it uses exact names like --verbose, so the typescript typings work.
  • it treats everything like it's optional.
  • it doesn't provide a --help guide.
  • maybe one day i'll add that stuff, but you can do that stuff in your own second pass.

Keywords

FAQs

Package last updated on 06 Jan 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc