
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
Basic argument parsing library using yargs-parser with built-in help screen
--version) with types, descriptions, aliases, and defaults._ property unless errorOnExtra is true.validate hook to check yargs parsed arguments before returning.preprocess hook to modify raw arguments before parsing.npm install basic-args
See index.d.ts for the full API.
const args = require('basic-args')({
name: 'basic-args-example',
version: '1.0.0',
description: 'A basic example of basic-args',
options: {
version: { type: String, description: 'Version to connect as', alias: 'v' },
port: { type: Number, description: 'Port to listen on', default: 25565 },
online: { type: Boolean, description: 'Whether to run in online mode' },
path: { type: String, description: 'Path to the server directory', default: '.' }
},
positionals: [
{ name: 'input', type: String, description: 'Input file path' },
{ name: 'output', type: String, description: 'Output file path' }
],
examples: [
'basic-args-example <inputFile> <outputFile> [--version str]',
'basic-args-example input.txt output.txt --version 1.16 Start server with version 1.16'
]
})
console.log(args)
Running the above with basic-args-example input.txt output.txt --version 1.16 (or using -v 1.16) yields:
{ input: 'input.txt', output: 'output.txt', version: '1.16', port: 25565, online: false, path: '.' }
Running with --help (or the configured helpCommand) displays the help screen:
basic-args-example - v1.0.0
A basic example of basic-args
Positionals:
input Input file path
output Output file path
Options:
--version, -v Version to connect as
--port Port to listen on (default: 25565)
--online Whether to run in online mode
--path Path to the server directory (default: .)
Usage:
basic-args-example input.txt output.txt --version 1.16 Start server with version 1.16
basic-args-example input.txt output.txt --version 1.16 Start server with version 1.16
name: Program name (shown in help).version: Program version (shown in help).description: Program description (shown in help).options: Object mapping option names to { type, description, alias?, default? }.positionals: Array of { name, type, description? } for required positional arguments.examples: Array of strings for usage examples in the help screen.errorOnExtra: If true, errors on unrecognized options (default: false).throwOnError: If true, throws errors instead of exiting (default: false).helpCommand: Command to trigger help screen (default: help).preprocess: Function to preprocess raw arguments.validate: Function to validate parsed arguments.positionals._ unless errorOnExtra is true.--online is true, not --online true). Use String type for custom handling.process.argv:require('basic-args')(options, ['--version', '1.16'])
import basicArg from 'basic-args'
const args = basicArg({
name: 'basic-args-example',
version: '1.0.0',
description: 'A basic example of basic-args',
throwOnError: false,
helpCommand: 'help',
options: {
version: { type: String, description: 'Version to connect as', alias: 'v' },
port: { type: Number, description: 'Port to listen on', default: 25565 },
online: { type: Boolean, description: 'Whether to run in online mode' },
path: { type: String, description: 'Path to the server directory', default: '.' }
},
positionals: [
{ name: 'input', type: String, description: 'Input file path' },
{ name: 'output', type: String, description: 'Output file path' }
],
examples: [
'basic-args-example input.txt output.txt --version 1.16 Start server with version 1.16',
'basic-args-example input.txt output.txt --port 8080 Start server on port 8080',
'basic-args-example input.txt output.txt --online Start server in online mode'
]
})
npm test
See history
1.5.0
FAQs
basic argument parser with built in help screen
The npm package basic-args receives a total of 615 weekly downloads. As such, basic-args popularity was classified as not popular.
We found that basic-args demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.