NOT FOUND
You just hit a route that doesn't exist... the sadness.
diff --git a/404.html b/404.html index e1ac9f6..bad5d44 100644 --- a/404.html +++ b/404.html @@ -48,7 +48,7 @@ } } }) -
You just hit a route that doesn't exist... the sadness.
You just hit a route that doesn't exist... the sadness.
You just hit a route that doesn't exist... the sadness.
You just hit a route that doesn't exist... the sadness.
Convert data to an arguments array.
+Convert data to an arguments array.
data
(object, optional)Format the configuration into a readable documentation string.
+Format the configuration into a readable documentation string.
commands
([string] | string)Determine if help was requested by returning zero to n commands if help is requested or null otherwise.
+Determine if help was requested by returning zero to n commands if help is requested or null otherwise.
params
([object] | object)Considering the above example, the commands ./myapp help
./myapp --help
and ./myapp -h
print the application help. The commands ./myapp help start
, ./myapp start --help
and ./myapp start -h
print the help of the start
command.
Considering the above example, the commands ./myapp help
./myapp --help
and ./myapp -h
print the application help. The commands ./myapp help start
, ./myapp start --help
and ./myapp start -h
print the help of the start
command.
Shell.js is written as an ESM package. It is also available as a CommonJS package. To import the package, uses:
+Shell.js is written as an ESM package. It is also available as a CommonJS package. To import the package, uses:
// ESM package
import { shell } from 'shell';
// CommonJS package
@@ -76,7 +76,7 @@
first argument. If the option "extended" is activated, it also receives the
original arguments and configuration as second and third arguments. Any user
provided arguments are transmitted as is as additional arguments.
-
Internal function used to load modules, see the load
option to pass a function or a module referencing the function.
TODO: Add a representative example
TODO: Add a representative example
Convert an arguments list to data.
+Convert an arguments list to data.
arguments
(process | string, optional, process
)process
.The route
method dispatch command into handler functions. An handler
is a function or the name of a module exporting a function. Learn more about routing in the usage documentation.
The route
method dispatch command into handler functions. An handler
is a function or the name of a module exporting a function. Learn more about routing in the usage documentation.
context
: [string] | object
The arguments to parse into data, accept the Node.js process instance, an argument list provided as an array of strings or the context object; optional, default to process
....users_parameters
: any
Additionnal parameters that will be passed to the handler function associated with a route.The application calling the route wait for the promise to be resolved with:
-await app.route(['start', '--port', 3000]
await app.route(['start', '--port', 3000]
Commands define the arguments passed to a Shell.js scripts.
The configuration parameter is an object passed as an argument to the function which is exported by this package.
+The configuration parameter is an object passed as an argument to the function which is exported by this package.
shell = require("shell")
app = shell(config)
const config = require('/etc/my_new_app')
const shell = require('shell')
const app = shell(config)
-console.log(app.parse())
Main is what is left once the option and the commands have been extracted. Like with options
, the main
property is defined at the application level or for each command.
The main
property is declared as an object with the following properties:
Usage of the "main" parameter is now: myapp server start [leftover]
.
Usage of the "main" parameter is now: myapp server start [leftover]
.
Options define the arguments passed to a shell scripts when prefixed with --
followed by their name or -
followed by their shortcut alternative.
The router
property is an object which provide low level access to modify the behaviour of the router plugin. Learn more about routing in the usage documentation.
The router
property is an object which provide low level access to modify the behaviour of the router plugin. Learn more about routing in the usage documentation.
promise
(boolean, false
)Note, the help
command, activated by default when a first command is registered, writes by default to stderr
and close the stream if stderr_end
is enabled.
Note, the help
command, activated by default when a first command is registered, writes by default to stderr
and close the stream if stderr_end
is enabled.
Shell.js is simple to configure. All it takes is a declarative object describing your application. Consider it like the model of your application. It is enriched by plugins such as to route commands and to generate help screens.
const shell = require("shell")
+ Why Shell.js?
Configure your CLI app
Shell.js is simple to configure. All it takes is a declarative object describing your application. Consider it like the model of your application. It is enriched by plugins such as to route commands and to generate help screens.
const shell = require("shell")
const app = shell({
name: "myapp",
description: "My CLI application",
@@ -104,7 +104,7 @@
EXAMPLES
myapp --help Show this message
- myapp help Show this message
Installing
The latest version of Shell.js is tested with Node.js 12, 14 and 16. New versions of Node.js shall work as well.
Via npm:
npm install shell
Via git (or downloaded tarball), copy or link the project from a discoverable Node.js directory:
git clone http://github.com/adaltas/node-shell.git
+ myapp help Show this message
The latest version of Shell.js is tested with Node.js 12, 14 and 16. New versions of Node.js shall work as well.
Via npm:
npm install shell
Via git (or downloaded tarball), copy or link the project from a discoverable Node.js directory:
git clone http://github.com/adaltas/node-shell.git
All notable changes to this project will be documented in this file. +
All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.
Note: Version bump only for package parameters
Note: Version bump only for package parameters
Note: Version bump only for package parameters
You are encouraged to contribute to Shell.js. The project is open sourced under the MIT license and it is hosted on GitHub. It is written and maintained by Adaltas, a consulting company based in Paris which specialized in Big Data.
Contributions go far beyond pull requests and commits. We are thrilled to receive a variety of other contributions including the following:
This package is developed by Adaltas.
This package is developed by Adaltas.
The Shell.js repository is hosted on GitHub.
+The Shell.js repository is hosted on GitHub.
The project is sponsored by Adaltas, a consulting company located in Paris and specialized in Big Data. They provide support and training on request.
If you’ve come across what you think is a bug or just want to make a feature request, open a new issue. Wether it is a bug report or a feature request, please spend some time to be clear and consised while providing a maximum of context.
You can get support by posting a new issue and browsing previous ones.
The documentation contains several example on every page. Do not hesitate to suggest us more examples and to help us improve the documentation.
The documentation contains several example on every page. Do not hesitate to suggest us more examples and to help us improve the documentation.
Copyright (c) 2011 Adaltas
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -64,7 +64,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.
For the sake of simplicity, the module operates by default in flatten mode. All the parameters of a multi-level command are merged toguether as one object. When parsing application arguments without commands, it doesn't make much a difference. However, when the application grew and more commands with deepest levels are created, there is a risk of collision between multiple options registering the same properties.
+For the sake of simplicity, the module operates by default in flatten mode. All the parameters of a multi-level command are merged toguether as one object. When parsing application arguments without commands, it doesn't make much a difference. However, when the application grew and more commands with deepest levels are created, there is a risk of collision between multiple options registering the same properties.
While being a little more verbose, the extended mode ensure that multi levels of options and main arguments can be defined with the same property name. The parameters are provided in the form of an array, one element per command.
Consider an application which registers a "config" property for the overall application as well as a start
command in flatten mode:
[
{ "config": "./config.yml" },
{ "command": "start", "config": "./start-config.yml" }
-]
Help prints detailed information about how to use the CLI application or one of its commands.
From a user perspective, there are multiple ways to print the help to the console:
@@ -111,7 +111,7 @@Routing dispatch the commands of the CLI application into user provided handler functions. Handler functions are defined with the route
property of the application or of a command.
Routing dispatch the commands of the CLI application into user provided handler functions. Handler functions are defined with the route
property of the application or of a command.
Help is automatically activated when using routing. A new help command is registered as well as the --help -h
option to each commands.
The router
configuration property define the routing behaviour. It is available at the application level as well as for every command. Refer to the router
configuration property for additional information.
Welcome to Shell.js! The goal of this tutorial is to guide you through configuring and building your first CLI application using Shell.js. Starting from scratch and go on to advanced usage of its APIs. The tutorial contains the following sections:
+Welcome to Shell.js! The goal of this tutorial is to guide you through configuring and building your first CLI application using Shell.js. Starting from scratch and go on to advanced usage of its APIs. The tutorial contains the following sections: