cliphp/args

Command line arguments

1.0.4 2018-07-06 17:23 UTC

This package is auto-updated.

Last update: 2025-01-12 20:05:45 UTC


README

Build Status

Library for command line arguments.

use Cliphp;

$args = new Args;

// Check for --help flag
if ($args->has('help')) {
    // show help message
}

// Get limit value
$limit = $args->get('limit') ?? 100;

Notes

The global $argv variable returns the script name (e.g. index.php) as the first value in the array. This library will shift the script name from the arguments list.

Available Methods

  • get(string $arg): mixed|null Returns value of an argument or NULL if it doesn't exist.
  • has(string $arg): bool Checks for existence of an argument
  • all(): array Get all of the arguments
  • count(): int Get count of arguments