Socket
Socket
Sign inDemoInstall

argue-cli

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    argue-cli

A thin and strongly typed CLI arguments parser for Node.js.


Version published
Weekly downloads
139K
decreased by-0.25%
Maintainers
1
Install size
48.1 kB
Created
Weekly downloads
 

Changelog

Source

2.1.0 (2022-10-14)

Features

  • node next module resolution for ts (#320) (ee15b2d)

Readme

Source

argue-cli

NPM version Node version Dependencies status Build status Coverage status Bundle size

A thin and strongly typed CLI arguments parser for Node.js.

Usage

  1. Install
# yarn
yarn add argue-cli
# pnpm
pnpm add argue-cli
# npm
npm i argue-cli
  1. Import in your code and use it!
import { read, end, expect, alias, option, readOptions } from 'argue-cli'

/**
 * Expect and read one of the commands
 */
const command = expect(
  alias('install', 'i'),
  'remove'
)
let options = {}

if (command === 'install') {
  /**
   * Read passed options
   */
  options = readOptions(
    option(alias('save', 'S'), Boolean),
    option(alias('saveDev', 'save-dev', 'D'), Boolean),
    option('workspace', String)
  )
}

/**
 * Read next argument
 */
const packageName = read()

/**
 * Expect end of the arguments
 */
end()

/* ... */

API

MethodDescription
function read(): string
Read next argument. Throws error if no next argument.
function end(): void
Expectation of the end. Throws an error if there are more arguments left.
function expect(...argRefs: ArgRef[]): string
Expect one of the given arguments.
function alias(name: string, ...aliases: string[]): AliasArgRef
Describe argument with aliases.
function option(argRef: ArgRef, type: PrimitiveConstructor): OptionReader
Describe option with value.
function readOptions(...optionReaders: OptionReader[]): OptionResult
Read options from arguments.

TypeScript

In API section types are described in a simplified way. Detailed example of the types you can see here.

Keywords

FAQs

Last updated on 14 Oct 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc