New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

yaf-argument-parser

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaf-argument-parser

A simple Argument-Parser with Actions

latest
Source
npmnpm
Version
0.9.8
Version published
Maintainers
1
Created
Source

Yet Another F@#%ing Argument Parser

A simple argument parsing library with nesting actions support. Each having it own set of parameter definitions.

Simple Example

import { ParameterDefinition, ArgumentParser } from "yaf-argument-parser"

const definitions: ParameterDefinition[] = [
    { name: "help", description: "", long: 'help' },
    { name: "testString", description: "", long: 'tstring', type: String },
    { name: "testNumber", description: "", long: 'tnumber', type: Number },
]
const args = process.argv.slice(2)

const argumentParser = new ArgumentParser(definitions)
console.log(argumentParser.parse(args))
node example.js
# --> { arguments: [], matches: {} }
node example.js --help
# --> { arguments: [], matches: { help: true } }
node out/test.js --tstring "bla blu" --tnumber 432
# --> { arguments: [], matches: { testString: 'bla blu', testNumber: 432 } }

Actions

Examples

import { Action, ParameterDefinition } from "yaf-argument-parser"

const definitionsMain: ParameterDefinition[] = [
    { name: "help", description: "" },
    { name: "verbose", description: "" }
]

const definitionsSearch: ParameterDefinition[] = [
    { name: "help", description: "" },
    { name: "path", description: "", type: String },
]

const args = process.argv.slice(2)

const mainAction = new Action('main', definitionsMain, (matchedArgs, additionalArguments) => {
    console.log("main", matchedArgs, additionalArguments)
})

const searchAction = new Action('search', definitionsSearch, (matchedArgs, additionalArguments) => {
    console.log("search", matchedArgs, additionalArguments)
})

mainAction.addSubAction(searchAction)
mainAction.run(args)
node example.js --verbose search --path "/home/user/"
# --> main { verbose: true } undefined
# --> search { path: '/home/user/' } []

Keywords

ts

FAQs

Package last updated on 07 Dec 2021

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