1.3.1 • Published 4 years ago

commander-init v1.3.1

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

commander-init

How to Use

const { CommanderInit } = require('../index');
const init = new CommanderInit(/*ApplicationName*/, /*path to json configuration file*/, /*path to script folder*/, /*optionnal path to json completion file*/);
init.parse(process.argv);

Command Generation

Script Command Generation

Command Structure

In order to have your commands generated, you will need exported functions in script files or folders into the given script folder.

The command will be the name of the script file or folder.

Each exported function will be a subcommand. Parameters of subcommands are the parameters of the script.

Documentation of the command will be the first line of the script if it is a commented line.

Parameter Specificities

The types of parameter are the following :

  • optional
  • required
  • variadic

By default, a script parameter is optionnal. Adding '/r/' or '/require'/ after the parameter definition will make it required in your command. Adding '/v/' or '/variadic'/ after the parameter definition will make it variadic in your command.

Configuration Command Generation

Given json configuration file will be read and keys extracted. Configuration command have by default an 'add' and a 'del' command to manipulate higher level configuration key. Each key will have default subcommand depending on there types.

  • array: add and del value command
  • object: add, get, del key command
  • other: name of the key as subcommand and new value and next parameter

Auto Completion of Script Commands

An optionnal given json completion file