PHP Classes

aSQL CLI: Parse and extract a command line arguments string

Recommend this page to a friend!
  Info   Example   Demos   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 177 All time: 8,750 This week: 455Up
Version License PHP version Categories
asql-cli 1.0.16BSD License5.3PHP 5, Console, Parsers
Description 

Author

This class can parse and extract a command line arguments string.

It takes a string with the arguments of a command and it parses it to extract the command options, flags and argument values.

The class returns as result an array with the values of each option, flag, or argument.

It can also rebuild the command line from the array of the parse results, so the command line parameters can be edited and rebuild from the edited parameters array.

Innovation Award
PHP Programming Innovation award nominee
February 2015
Number 7


Prize: One downloadable copy of CodeLobster Professional
Many applications started from a command line shell need a way to parse and extract the command values passed to them.

This class not only can parse command line arguments, but also can rebuild a command line string using previously parsed commands.

This allows implementing a way to edit command lines programmatically but changing the values of a parsed command line and rebuilding the command line string from the changed values.

Manuel Lemos
Picture of Melanie Wehowski
  Performance   Level  
Innovation award
Innovation award
Nominee: 12x

 

Example

<?php
error_reporting
(E_ALL);

$dir_lib = __DIR__. DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR;

$file = $dir_lib.'frdl' .DIRECTORY_SEPARATOR.'aSQL'.DIRECTORY_SEPARATOR. 'Engines'.DIRECTORY_SEPARATOR.'Terminal'.DIRECTORY_SEPARATOR.'CLI.php';

$testfile = $dir_lib.'frdl' .DIRECTORY_SEPARATOR.'aSQL'.DIRECTORY_SEPARATOR. 'Engines'.DIRECTORY_SEPARATOR.'Terminal'.DIRECTORY_SEPARATOR.'Test.php';

require
$file;
require
$testfile;

$Terminal = new frdl\aSQL\Engines\Terminal\Test();


  Files folder image Files (16)  
File Role Description
Files folder imageCommand (9 files)
Files folder imagelib (1 directory)
Accessible without login Plain text file CLI.php Class Base class
Accessible without login Plain text file Console.php Example Example implementation
Accessible without login Plain text file example.php Example Example
Accessible without login Plain text file LICENSE.md Lic. License
Accessible without login Plain text file Test.php Example Example

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 75%
Total:177
This week:0
All time:8,750
This week:455Up