From 94c816e14e3984f5c06b78d617e62b5e62b079a9 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Mon, 21 Aug 2023 20:34:26 +0300 Subject: [PATCH 1/3] Updated Sample App --- example/app/app | 4 ++++ example/app/app.php | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 example/app/app diff --git a/example/app/app b/example/app/app new file mode 100644 index 0000000..6af0539 --- /dev/null +++ b/example/app/app @@ -0,0 +1,4 @@ +#!/usr/bin/env php +register(new HelpCommand()); $runner->register(new HelloWorldCommand()); $runner->register(new OpenFileCommand()); -$runner->start(); +$runner->setDefaultCommand('help'); + +exit($runner->start()); From 7384fd3a1f62a2c2fb9d78b200c18b917abf8380 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Mon, 21 Aug 2023 20:46:10 +0300 Subject: [PATCH 2/3] 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 Date: Sun, 3 Dec 2023 21:30:52 +0300 Subject: [PATCH 3/3] Added PHP 8.3 --- .github/workflows/php83.yml | 68 +++++++++++++++++++++++++++++++++++++ README.md | 22 ++++++------ 2 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/php83.yml diff --git a/.github/workflows/php83.yml b/.github/workflows/php83.yml new file mode 100644 index 0000000..b4d8217 --- /dev/null +++ b/.github/workflows/php83.yml @@ -0,0 +1,68 @@ +name: Build PHP 8.3 + +on: + push: + branches: [ main, dev ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ${{ matrix.os }} + services: + sql.data: + image: mcr.microsoft.com/mssql/server:2019-latest + env: + SA_PASSWORD: 1234567890@Eu + ACCEPT_EULA: Y + MSSQL_PID: Express + ports: + - "1433:1433" + strategy: + fail-fast: true + matrix: + os: [ ubuntu-latest ] + php: [8.3] + + name: PHP${{matrix.php}} - ${{matrix.os}} + + steps: + - name: Clone Repo + uses: actions/checkout@v1 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: mysqli, mbstring, sqlsrv + tools: phpunit:9.5.20, composer + + - name: Shutdown Ubuntu MySQL + run: sudo service mysql stop + + - name: Set up MySQL + uses: mirromutth/mysql-action@v1.1 + with: + mysql version: '5.7' + mysql database: 'testing_db' + mysql root password: 123456 + mysql user: 'root' + mysql password: 123456 + + - name: Wait for MySQL + run: | + while ! mysqladmin ping --host=127.0.0.1 --password=123456 --silent; do + sleep 1 + done + + - name: Setup MSSQL + run: sqlcmd -S localhost -U SA -P 1234567890@Eu -Q 'create database testing_db' + + - name: Install Dependencies + run: composer install --prefer-dist --no-interaction --no-dev + + - name: Execute Tests + run: phpunit + + - name: CodeCov + uses: codecov/codecov-action@v1 \ No newline at end of file diff --git a/README.md b/README.md index 3841e3b..4491a59 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ Class library that can help in writing command line based applications with mini

- - + + @@ -42,15 +42,15 @@ Class library that can help in writing command line based applications with mini ## Supported PHP Versions | Build Status | |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| -| | -| | -| | -| | -| | -| | -| | -| | - +| | +| | +| | +| | +| | +| | +| | +| | +| | ## Features