
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
@wcauchois/program-builder
Advanced tools
[](https://badge.fury.io/js/%40wcauchois%2Fprogram-builder) [](https://circleci.com/gh/wcauchois/p
This is a TypeScript-first library for building type safe command-line interfaces.
You define your arguments and keyword arguments using a fluent builder, which gives you a Program
object. You can then define a main
function in terms of the strongly typed arguments of that Program
, and finally execute the main function against your program which will parse and provide commandline arguments.
Documentation Website | Examples | API Docs
npm install @wcauchois/program-builder
--unroll-loops
; and "inverted", like --no-unroll-loops
).--path foo.txt
. These can be strings, integers, or floats - or you can provide
a custom conversion function.-h
, --help
).main
functions and correctly exits the process.const program = ProgramBuilder.newBuilder()
.arg('filename', { description: `A file name` })
.optionalArg('extraFilename', { description: `An additional optional file name`})
.intFlag('--optionalCount,-c', { dest: 'optionalCount', default: null, description: `A count` })
.intFlag('--requiredCount', { dest: 'requiredCount', description: `A count that is required` })
.build();
function main(args: Arguments<typeof program>) {
console.log(`filename is: ${args.filename}`); // args.filename: string
console.log(`extraFilename is: ${args.extraFilename}`); // args.extraFilename: string | null
console.log(`optionalCount is: ${args.count}`); // args.optionalCount: number | null
console.log(`requiredCount is: ${args.requiredCount}`); // args.requiredCount: number
}
program.exec(main);
An example invocation of this program would be:
$ ts-node main.ts file1.txt file2.txt -c 1 --requiredCount 2
You can also view autogenerated help text by executing the program with an -h
parameter.
$ ts-node main.ts -h
Usage: main.ts [options] <filename> [extraFilename]
Options:
--count, -c [count] A count
--requiredCount [requiredCount] A count that is required
As of January 2020, Program Builder is a very young library! That said, I think it occupies a valuable niche offering better type safety than yargs or commander with less verbosity than ts-command-line.
The argument parsing library that gives me the most joy is Python's argparse and I'm striving to create something similarly lightweight but powerful for TypeScript.
At this stage your feedback is extremely valuable, and if you have anything to say, please file an issue!
FAQs
[](https://badge.fury.io/js/%40wcauchois%2Fprogram-builder) [](https://circleci.com/gh/wcauchois/p
The npm package @wcauchois/program-builder receives a total of 1,825 weekly downloads. As such, @wcauchois/program-builder popularity was classified as popular.
We found that @wcauchois/program-builder demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.