Inversify Commander Utils
Summary
The project assembles the functionality of two libraries: commander and inversifyjs. It represents the commander functionality in inversify way.
Installation
You can install inversify-commander-utils
using npm:
npm install inversify inversify-commander-utils reflect-metadata --save
The inversify-commander-utils
type definitions are included in the npm module and require TypeScript 2.0.
Please refer to the InversifyJS documentation to learn more about the installation process.
Basics
Step 0: Imports for a tutorial below.
;;;;
Step 1: Define containers
Step 2: Define a group and actions
The group is represented as a container where we inject another container to. The injected container is available in actions of the group.
Step 3: Assembling of all definitions
;container.bindTodoContainer.toTodoContainer;registerGroupscontainer;buildprogram, container;
Step 4: Processing of arguments
commander .parseprocess.argv;
Step 5: Run it from the console
node ./src/cli.js printer:A A4 -c 3
P.S.
InversifyJS is a very interesting library. We are developing a web application using the approach. At first we used InversifyJS utility alone. Later we checked a module inversify-express-utils, studied it better added some functionality. And we realized that this is a good example to wrap any module for our needs. This is used in our projects and it is being upgraded. Maybe another modules will also be wrapped.