Table of Contents
Installation
To install the stable version:
yarn add triviality-commander
This assumes you are using yarn as your package manager.
or
npm install triviality-commander
Triviality commander
Add integration for Commander in Triviality.
- Add option to split commands configuration over multiple Modules into multiple configuration services.
- Exposes Module for automatic version based on your package.json
- StartCommanderService service that response when no valid command is given.
Example
Example commander configuration:
;;
Module with configuration added to the configuration registry:
;;;;
Add the module to the ContainerFactory
;;;; ContainerFactory .create .addCommanderModule .addCommanderPackageVersionModule .addCommanderExampleModule .build .then;
if we run the file, we can call the actual commands.
./node_modules/.bin/ts-node example/bootstrap.ts hello worldhello world
./node_modules/.bin/ts-node example/bootstrap.ts bye worldbye world
./node_modules/.bin/ts-node example/bootstrap.ts hello world --shoutHELLO WORLD
Version
CommanderPackageVersionModule exposes automatic version to commander based on your package.json
./node_modules/.bin/ts-node example/bootstrap.ts --version0.4.0
Usage
To create a terminal application you can best use ts-node. Call your typescript service container from there.
#!/usr/bin/env node require"ts-node/register";require"./example/bootstrap";
Don't forget to give it executable permissions (chmod +x ./cli.js).
Now you can directly run your commands:
./cli.js hello world -sHELLO WORLD
./cli.js bye worldbye world
Thanks
Special thanks to:
- Eric Pinxteren