consultant
What is the Consultant?
Consultant is a JavaScript library which allows you gathering options from various sources such as command line, optstring or interactive menu.
Provides:
- Well-defined input model for operations require parameters.
- Declerative approach.
- Multiple methods for getting parameter (or options)
- Parsing command line input like
cmd --parameter=value --option1 --option2
. - Interactive command line user interface to getting options directly from user.
- Parsing command line input like
- Prepares an help output based on model definition.
Quick start
Execute npm install consultant
to install consultant and its dependencies into your project directory.
Usage
; const rules = label: 'sample menu' children: plugins: type: Consultanttypescommand aliases: 'p' id: 'plugins' label: 'Plugin commands' description: 'Add/list plugins' children: add: type: Consultanttypescommand id: 'plugins-add' label: 'Add' description: 'Adds a plugin' repo: type: ConsultanttypesstringParameter label: 'Repo' description: 'Specifies repo address' 'default': 'http://github.com/eserozvataf/' min: 0 max: 1 makefile: type: ConsultanttypesstringParameter aliases: 'f' label: 'Makefile' description: 'Load tasks from FILE' parameter: 'FILE' 'default': 'makefile.js' min: 0 max: undefined valuelength >= 3 || 'minimum 3 chars required' tasks: type: ConsultanttypesbooleanParameter aliases: 't' label: 'Tasks' description: 'Lists defined tasks' 'default': false verbosity: type: ConsultanttypesstringParameter label: 'Verbosity' description: 'Sets verbosity of log messages [debug, warn, info, error]' 'default': 'info' values: 'debug' 'warn' 'info' 'error' min: 0 max: 1 version: type: ConsultanttypesbooleanParameter aliases: 'v' label: 'Version' description: 'Displays the jsmake version' 'default': false help: type: ConsultanttypesbooleanParameter aliases: 'h' '?' label: 'Help' description: 'Displays this help message' 'default': false ; const params = rules; // string parsingconst input1 = await params;console; // plugins-addconsole; // [ 'testfile.js' ] // command line parsingconst input2 = await params;console; // info // command line user interfaceconst input3 = await params;
Todo List
See GitHub Projects for more.
Requirements
- node.js (https://nodejs.org/)
License
Apache 2.0, for further details, please see LICENSE file
Contributing
See contributors.md
It is publicly open for any contribution. Bugfixes, new features and extra modules are welcome.
- To contribute to code: Fork the repo, push your changes to your fork, and submit a pull request.
- To report a bug: If something does not work, please report it using GitHub Issues.