argcom
argcom
is a straightforward CLI argument parser with no added complexity or opinions.
Installation
To install the package, use npm:
pnpm add argcom
yarn install argcom
npm install argcom
Usage
argcom()
accepts one or two arguments:
- A command line specification object.
- An optional options object, which defaults to
{ permissive: false, argv: process.argv.slice(2), stopAtPositional: false }
.
It returns an object containing the command-line values. Any parameters not used by options are placed in the result._
array, which is always returned (even if empty). argcom()
does not validate or enforce requirements—this is up to the application.
import { argcom } from 'argcom';
const args = arg({
'--help': Boolean,
'--version': Boolean,
'--verbose': arg.COUNT,
'--port': Number,
'--host': String,
'--tag': [String],
'-v': '--verbose',
'-h': '--host',
'--domain': '--host'
});
console.log(args);
tsup
Bundle your TypeScript library with no config, powered by esbuild.
https://tsup.egoist.dev/
How to use this
- install dependencies
# pnpm
$ pnpm install
# yarn
$ yarn install
# npm
$ npm install
- Add your code to
src
- Add export statement to
src/index.ts
- Test build command to build
src
.
Once the command works properly, you will see dist
folder.
# pnpm
$ pnpm run build
# yarn
$ yarn run build
# npm
$ npm run build
- Publish your package
$ npm publish
test package
https://www.npmjs.com/package/argcom