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(4mo ago)0701PHPPHP ^8.1

Since Jun 28Pushed 4mo 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 3w 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

37

—

LowBetter than 81% of packages

Maintenance76

Regular maintenance activity

Popularity8

Limited adoption so far

Community10

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

129d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/45892756?v=4)[Ali Kamel](/maintainers/ali-eltaweel)[@ali-eltaweel](https://github.com/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

[seld/cli-prompt

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

24726.4M22](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

13045.3M6.2k](/packages/illuminate-console)[winbox/args

Windows command-line formatter

20718.9k21](/packages/winbox-args)

PHPackages © 2026

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