Socket
Socket
Sign inDemoInstall

argsclopts

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

argsclopts

cliclopts but for Node.js parseArgs


Version published
Weekly downloads
136
decreased by-2.16%
Maintainers
1
Weekly downloads
 
Created
Source

argsclopts

latest version Actions Status Coverage Status downloads Types in JS Socket Badge

cliclopts but for Node.js parseArgs. A library that formats standard usage strings using the node:util parseArgs options object shape with an additional help field added to it.

npm install argsclopts

Usage

import { formatHelpText, printHelpText } from 'argsclopts'
import { join } from 'node:path'
import { parseArgs } from 'node:util'

const pkgPath = join(import.meta.dirname, 'package.json')

/** @type {ArgscloptsParseArgsOptionsConfig} */
const options = {
  foo: {
    type: 'boolean',
    short: 'f',
    help: 'A foo flag thats a boolean'
  },
  bar: {
    type: 'string',
    help: 'A bar flag thats a string'
  }
}

await printHelpText({
  options,
  pkgPath
})
/*

Usage: argsclopts [options]

    Example: argsclopts

    --foo, -f             A foo flag thats a boolean
    --bar                 A bar flag thats a string

argsclopts (v1.0.0)

 */

const args = ['-f', '--bar', 'b']
const { values } = parseArgs({ args, options })
// { foo: true, bar: 'b' }

License

MIT

FAQs

Package last updated on 27 Dec 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