<commit_before>[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
# CliArgs v1.0.0 for PHP >= 5.5

## About
Class **CliArgs** helps to get options from the command line argument list easy.

## Features
- CliArgs uses **$GLOBAL['argv']** as base, and it does not use function **getopt()**.
- It does not implement logic for 'required', it should be in your side.
- It helps to get options easy from command line argument list.
- It generates help info about options based on config.
- Flexible configuration and data filtering.

## Note
This class is not workable when [register_argc_argv](http://php.net/manual/en/ini.core.php#ini.register-argc-argv) is disabled.

## Usage

### Config

Note: all params from cli that you want to use should be specified in config, otherwise they will be ignored.
```php
$config = [
    // You should specify key as name of option from the command line argument list.
    // Example, name <param-name> for --param-name option
    'param-name' => [

        'alias' => 'p',
            // [optional], [string]
            // Alias helps to have short or long name for this key.
            // Example, name <p> for -p option

        'default' => false,
            // [optional], [mixed], [default = null]
            // Default value will returned if param is not setted
            // or params has not value.

        'help' => 'Some description about param',
            // [optional], [string]
            // Text that will returned, if you request help<commit_msg>pre release v1.0.0<commit_after>[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
# CliArgs v1.0.0 for PHP >= 5.5

## About
Class **CliArgs** helps to get options from the command line argument list easy.

## Features
- CliArgs uses **$GLOBAL['argv']** as base, and it does not use function **getopt()**.
- It does not implement logic for 'required', it should be in your side.
- It helps to get options easy from command line argument list.
- It generates help info about options based on config.
- Flexible configuration and data filtering.

## Note
This class is not workable when [register_argc_argv](http://php.net/manual/en/ini.core.php#ini.register-argc-argv) is disabled.

## Usage

### Example

run
```
> example.php --name=Alexander --age=32 --sex=m
or
> example.php -n Alexander -a 32 -s m
```

example.php
```php
$config = [
    'name' => 'n',
    'age' => 'a',
    'sex' => 's'
];
$CliArgs = new CliArgs($config);

echo $CliArgs->getArg('name'); // Alexander
echo $CliArgs->getArg('n'); // Alexander

echo $CliArgs->getArg('age'); // 42
echo $CliArgs->getArg('a'); // 42

echo $CliArgs->getArg('sex'); // m
echo $CliArgs->getArg('s'); // m
```

### Config

Note: all params from cli that you want to use should be specified in config, otherwise they will be ignored.
```php
$config = [
    // You should specify key as name of option from the command line argument list.
    // Example, name <param-name> for --param-name option
    'param-name' => [

        'alias' => 'p',
            // [optional], [string]
            // Alias helps to have short or long name for this key.
            // Example, name <p> for -p option

        'default' => false,
            // [optional], [mixed], [default = null]
            // Default value will returned if param is not setted
            // or params has not value.

        'help' => 'Some description about param',
            // [optional], [string]
            // Text that will returned, if you request help
{'fraction_non_alphanumeric': 0.13765294771968856, 'fraction_numerical': 0.005839822024471635, 'mean_word_length': 2.739085239085239, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1130525', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1037, 'n_words': 411}