From 7384fd3a1f62a2c2fb9d78b200c18b917abf8380 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Mon, 21 Aug 2023 20:46:10 +0300 Subject: [PATCH] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6df032f..3841e3b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # WebFiori CLI -Class library that can help in writing command line based applications using PHP. +Class library that can help in writing command line based applications with minimum dependencies using PHP.

@@ -73,7 +73,7 @@ To install the library, simply include it in your `composer.json`'s `require` se ### Creating a Command -First step in creating new command is to create a new class that extends the class `CLICommand`. The class `CLICommand` is a utility class which has methods which can be used to read inputs, send outputs and use command line arguments. +First step in creating new command is to create a new class that extends the class `webfiori\cli\CLICommand`. The class `CLICommand` is a utility class which has methods that can be used to read inputs, send outputs and use command line arguments. The class has one abstract method that must be implemented. The code that will exist in the body of the method will represent the logic of the command. @@ -98,7 +98,7 @@ class SampleCommand extends CLICommand { ### Running a Command -The class `Runner` is the class which is used to manage the logic of executing the commands. In order to run a command, an instance of this class must be created and used to register the command and start running the application. +The class `webfiori\cli\Runner` is the class which is used to manage the logic of executing the commands. In order to run a command, an instance of this class must be created and used to register the command and start running the application. To register a command, the method `Runner::register()` is used. To start the application, the method `Runner::start()` is used. @@ -112,7 +112,7 @@ use SampleCommand; $runner = new Runner(); $runner->register(new SampleCommand()); -$runner->start(); +exit($runner->start()); ``` Now if terminal is opened and following command is executed: @@ -154,7 +154,7 @@ class SampleCommand extends CLICommand { ``` -Arguments provided as an associative array. Index is name of the argument and the value of the index is sub-associative array of options. Each argument can have the following options: +Arguments can be provided as an associative array or array of objects of type `webfiori\cli\CommandArgument`. In case of associative array, Index is name of the argument and the value of the index is sub-associative array of options. Each argument can have the following options: * `optional`: A boolean. if set to true, it means that the argument is optional. Default is false. * `default`: An optional default value for the argument to use if it is not provided. * `description`: A description of the argument which will be shown if the command `help` is executed. @@ -217,7 +217,7 @@ One of the commands which comes by default with the library is the `help` comman ### Setting Help Instructions -Help instructions are provided by the developer who created the command during its implementation. Instructions can be set on the constructor of the class that extends the class `CLICommand` as a description. The description can be set for the command and its arguments. +Help instructions are provided by the developer who created the command during its implementation. Instructions can be set on the constructor of the class that extends the class `webfiori\cli\CLICommand` as a description. The description can be set for the command and its arguments. ``` php