
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
argparse-ts
Advanced tools
Modern CLI arguments parser for node.js (TypeScript / JavaScript).
npm i argparse-ts
import { ArgsParser } from "argparse-ts";
const parser = new ArgsParser([
{
name: 'container',
description: "Container name",
type: 'string',
},
{
name: 'operations',
description: "Operations to run",
type: 'string',
nargs: '+',
choices: ['build', 'clear', 'sync', 'start', 'stop'],
},
{
name: '--mode',
description: "Run mode",
type: 'string',
nargs: '?',
choices: ['dev', 'test', 'prod'],
default: 'prod',
},
{
name: '--cpu',
description: "CPU cores count to use",
type: 'number',
nargs: '?',
default: 1,
},
{
name: '--use-gpu',
description: "Use GPU flag",
type: 'boolean',
const: true,
default: false,
},
{
name: '--extra-services',
alias: '-e',
description: "Extra services to include",
type: 'string',
nargs: '*',
},
]);
console.log(parser.help);
/*
Positional arguments:
container <string> Container name
Type: string (not empty)
operations <string> <string> ...
Operations to run
Type: Array<string> (not empty)
Allowed values: build, clear, sync, start, stop
Options:
--mode <string> Run mode
Type: string
Default value: "prod"
Allowed values: dev, test, prod
--cpu <number> CPU cores count to use
Type: number
Default value: 1
--use-gpu Use GPU flag
Type: boolean
Default value: false
-e <string> <string> ..., --extra-services <string> <string> ...
Extra services to include
Type: Array<string>
*/
const argv = ['main', 'clear', 'build', 'start', 'sync', '--mode', 'dev', '--use-gpu', '-e', 'logger', 'profiler', 'tester'];
const parsedArgs = parser.parse(argv);
console.log(parsedArgs.positional);
/*
{
'container': 'main',
'operations': ['clear', 'build', 'start', 'sync'],
}
*/
console.log(parsedArgs.options);
/*
{
'mode': 'dev',
'cpu': 1,
'use-gpu': true,
'extra-services': ['logger', 'profiler', 'tester'],
}
*/
const containerName = parsedArgs.get<string>('container');
console.log(containerName); // 'main'
const operations = parsedArgs.get<string[]>('operations');
console.log(operations); // ['clear', 'build', 'start', 'sync']
const mode = parsedArgs.get<string>('--mode');
console.log(mode); // dev
const cpuCount = parsedArgs.get<number>('--cpu');
console.log(cpuCount); // 1
const useGpu = parsedArgs.get<boolean>('--use-gpu');
console.log(useGpu); // true
For detailed documentation and usage examples, please refer to API documentation
npm i
npm run test
ArgParse TS is licensed under the MIT License.
FAQs
Modern CLI arguments parser for node.js
We found that argparse-ts 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.