Recommend this page to a friend! |
Classes of Andrey Postal | EasyCLI | doc/01-usage.md | Download |
|
DownloadUsing CLI
Installation
Get started> For a basic and straight-forward project check this example. The main idea is keep things simple. To start your new CLI project you will need to create a new App or extend it in a command class like we did in the Complete Example. In order to create a new app you have to define some information like the App
name, description and cmd. This information will be used by the builtin
helper command <div style="text-align: center;">
</div> ConceptsA quick overview for the core concepts used in the library AppThe app is the main container for the application. On it, you will define the commands and can also add global parameters that all the commands will have access to.
CommandA command is an action itself. Is where the application behavior should be implemented. We can have multiple instances in an application, and we can define the parameters that are only valid in the context for this specific command. > Examples:
ParamThe parameters are the definitions for the data that we receive in the arguments
when calling the CLI. If a parameter is a boolean flag only (has no value) the
attribute
ServiceThe service is the caller to the implementation itself. Here is where the real action happens. When calling the service we will always pass to it as an argument the Context of the current run (see next). Related to the definition of the service itself, it can be done in two different ways:
ContextThe context is a wrapper for the parsed parameters. You can access any parameter by passing its flag or key, both are accessible even when not used. If a parameter is required, it is guaranteed that it will exist in the context (both for the key and flag) but if it is optional a null value will be returned when the field is not present. |