You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

valon-args

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valon-args

Typescript node argument parser with strong types.

3.0.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Valon Args

Typescript node argument parser with strong types.

npm npm Build & Tests

Installation

# npm
npm install valon-args

# Yarn
yarn add valon-args

# Pnpm
pnpm add valon-args

Example

import { cliArgs } from 'valon-args'

const options = cliArgs({
    name: { type: 'string', required: true },
    retries: { type: 'number' },
    force: { type: 'boolean' },
})

// All args are now typed and validated.
options.name // string
options.retires // number | undefined
options.force // boolean | undefined

Documentation

import { cliArgs } from 'valon-args'

// Console args are automaticly parsed fron the terminal.
const args = cliArgs({ name: { type: 'string' } })

Usage

String

node ./example.js --string=foo // 'foo'
node ./example.js --string="foo bar" // 'foo bar'

String[]

node ./example.js --string=foo --string=bar // ['foo', 'bar']
node ./example.js --string="foo bar" --string="bar baz" // ['foo bar', 'bar baz']
node ./example.js --string "foo bar" foobar "bar baz" // ['foo bar', 'foobar', 'bar baz']

Number

node ./example.js --number=1 // 1

Number[]

node ./example.js --number=1 --number=2 // [1, 2]

Boolean

node ./example.js --force // true
node ./example.js --force=true // true
node ./example.js --force=false // false
node ./example.js --force=1 // true
node ./example.js --force=0 // false
node ./example.js // undefined

Keywords

typescript

FAQs

Package last updated on 29 Jan 2024

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