vendimia/clap

Command-line argument parser

0.3 2025-07-30 01:22 UTC

This package is auto-updated.

Last update: 2025-07-30 02:25:20 UTC


README

PHP command-line argument parser.

use Vendimia\Clap\Parser;

function createUser($username, bool $admin = false)
{
    if ($admin) {
        echo "Creating admin user {$username}...";
    } else {
        echo "Creating user {$username}...";
    }
}

$cli = new Parser;
$cli->register(createUser(...));

$cli->process();

Calling this script will execute function createUser() with the first CLI argument as $username. If '--admin' argument is passed to the script, it will pass true to $admin.

php createuser.php john