GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - phalcon/cli-options-parser: Command line arguments/options parser to use in Phalcon applications.

BranchesTags
Open more actions menu

Latest commit

 

History

148 Commits
148 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
bin
bin
 
 
config
config
 
 
docs
docs
 
 
public
public
 
 
resources
resources
 
 
src
src
 
 
tests
tests
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CODE_OWNERS.TXT
CODE_OWNERS.TXT
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
composer.lock
composer.lock
 
 
docker-compose.yml
docker-compose.yml
 
 

Repository files navigation

Phalcon - CLI Options Parser

CLI Options Parser CI Quality Gate Status Coverage PDS Skeleton Downloads

Command line arguments/options parser.

Requirements

  • PHP >= 8.0

Installation

You can install the package using composer

composer require phalcon/cli-options-parser

Usage

use Phalcon\Cop\Parser;

$parser = new Parser();

// Parse params from the $argv
$params = $parser->parse($argv);

// Parse params from the $_SERVER['argv']
$params = $parser->parse();

// After parsing input, Parser provides a way to get booleans:
$parser->getBoolean('foo');

// Get param `foo` or return TRUE as a default value
$parser->getBoolean('foo', true);

Examples

php test.php -az value1 -abc value2
[
    'a' => 'value2',
    'z' => 'value1',
    'b' => 'value2',
    'c' => 'value2',
]

php test.php -a value1 -abc value2
[
    'a'  => 'value2',
    'b'  => 'value2',
    'c'  => 'value2',
]

php test.php --az value1 --abc value2
[
    'az'  => 'value1',
    'abc' => 'value2',
]

php test.php --foo --bar=baz --spam eggs
[
    'foo'  => true,
    'bar'  => 'baz',
    'spam' => 'eggs',
]

php test.php -abc foo
[
    'a' => 'foo',
    'b' => 'foo',
    'c' => 'foo',
]

php test.php arg1 arg2 arg3
[
    0 => 'arg1',
    1 => 'arg2',
    2 => 'arg3',
]

Development

The repository ships a Docker setup for local development and testing. You only need Docker + Docker Compose; the PHP runtime is provided inside the container.

Quick start

docker compose up -d --build
docker compose exec app composer install
docker compose exec app composer test

app is the Compose service name; the running container is cli-options-parser-app. It stays up via a sleep infinity keepalive, so you can docker compose exec app <cmd> freely.

Choosing the PHP version

The image is built for one PHP version at a time via the PHP_VERSION build arg (default 8.4; supported 8.0–8.4). Because it is a build arg, changing it requires a rebuild:

docker compose up -d --build                  # PHP 8.4 (default)
PHP_VERSION=8.0 docker compose up -d --build  # PHP 8.0

Composer scripts

Script Description
composer cs PHP_CodeSniffer (PSR-12)
composer cs-fix Auto-fix coding-standard issues (phpcbf)
composer cs-fixer PHP CS Fixer (dry-run)
composer cs-fixer-fix Apply PHP CS Fixer
composer analyze PHPStan static analysis (level max)
composer test Unit tests (PHPUnit)
composer test-coverage Tests + Clover coverage (tests/_output/coverage.xml)

License

CLI Options Parser is open source software licensed under the BSD-3-Clause License.

© Phalcon Team

About

Command line arguments/options parser to use in Phalcon applications.

phalcon.io

Topics

clicommandcommand-linegetoptlineoptionparserphalcon

Resources

Readme
BSD-3-Clause license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

18 stars

Watchers

9 watching

Forks

8 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.