PHPackages                             ali-eltaweel/command-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. ali-eltaweel/command-parser

ActiveLibrary[CLI &amp; Console](/categories/cli)

ali-eltaweel/command-parser
===========================

Shell-style Command-line Parser.

1.2.1(2mo ago)0701PHPPHP ^8.1

Since Jun 28Pushed 2mo agoCompare

[ Source](https://github.com/ali-eltaweel/command-parser)[ Packagist](https://packagist.org/packages/ali-eltaweel/command-parser)[ RSS](/packages/ali-eltaweel-command-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (1)

Command Parser
==============

[](#command-parser)

**Shell-style Command-line Parser**

- [Command Parser](#command-parser)
    - [Installation](#installation)
    - [Usage](#usage)
        - [Defining Commands](#defining-commands)
        - [Parsing Commands](#parsing-commands)

---

Installation
------------

[](#installation)

Install *command-parser* via Composer:

```
composer require ali-eltaweel/command-parser
```

Usage
-----

[](#usage)

### Defining Commands

[](#defining-commands)

```
use CommandParser\Specs\{ Command, Operand, Option, OptionToken, OptionTokenType };

$git = new Command(

    name: 'git',
    description: 'Git command-line interface',
    options: [
        new Option(
            name: 'help',
            description: 'Display help information',
            isRepeatable: false,
            isFlag: true,
            tokens: [
                new OptionToken(token: 'help', type: OptionTokenType::Extended)
            ]
        )
    ],
    operands: [],
    subCommands: [
        new Command(
            name: 'commit',
            description: 'Record changes to the repository',
            options: [
                new Option(
                    name: 'message',
                    description: 'Use the given  as the commit message',
                    isRepeatable: false,
                    isFlag: false,
                    tokens: [
                        new OptionToken(token: 'm', type: OptionTokenType::Short),
                        new OptionToken(token: 'message', type: OptionTokenType::Long)
                    ]
                )
            ],
            operands: [],
            subCommands: []
        ),
        new Command(
            name: 'push',
            description: 'Update remote refs along with associated objects',
            options: [
                new Option(
                    name: 'force',
                    description: 'Force update of the remote ref',
                    isRepeatable: false,
                    isFlag: true,
                    tokens: [
                        new OptionToken(token: 'f', type: OptionTokenType::Short),
                        new OptionToken(token: 'force', type: OptionTokenType::Long)
                    ]
                )
            ],
            operands: [
                new Operand(index: 0, name: 'remote', description: 'The remote repository to push to'),
                new Operand(index: 1, name: 'branch', description: 'The branch to push')
            ],
            subCommands: []
        )
    ]
);
```

### Parsing Commands

[](#parsing-commands)

```
use CommandParser\CommandLineParser;

$parser = new CommandLineParser();

$commandLine = $parser->parse(['git', 'commit', '-m', 'Initial commit'], $git);
$commandLine = $parser->parse(['git', 'push', 'origin', 'main'], $git);
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance83

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~77 days

Total

4

Last Release

84d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7564e10ba11b25d8700726a92f669e38be2ff9191e8f6ccdfafc36678ffab2b8?d=identicon)[ali-eltaweel](/maintainers/ali-eltaweel)

---

Top Contributors

[![ali-eltaweel](https://avatars.githubusercontent.com/u/45892756?v=4)](https://github.com/ali-eltaweel "ali-eltaweel (6 commits)")

### Embed Badge

![Health badge](/badges/ali-eltaweel-command-parser/health.svg)

```
[![Health](https://phpackages.com/badges/ali-eltaweel-command-parser/health.svg)](https://phpackages.com/packages/ali-eltaweel-command-parser)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M319](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M18](/packages/consolidation-annotated-command)[chi-teck/drupal-code-generator

Drupal code generator

26947.8M5](/packages/chi-teck-drupal-code-generator)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
