MMOframework
Pourquoi l'IA Playground Bibliothèques Développeurs Agence
FR EN
Créer un projet en direct
Index

ShellManual

MMO\core\classes · 1 symbole · générée le 30 Nov 2026

class

ShellManual

ShellManual.php:34
The manual of a command-line application: every 'SHELL' command of every shell controller the application routes (mmo.edms', mmo.git's and the application's own AdminController in my.oviepro's admin.php), read from their #[Command]/#[InteractiveCommand] attributes, rendered as a recap (one line per command, by group), as the detail of one command (a man page), as json or as markdown. [`aShellController::route_help`](https://mmoframework.fr/fr/documentation/mmo.core/php/classes/aShellController.md#ashellcontroller-route-help) prints it.class MMO\core\classes\ShellManual implements JsonSerializable
Espace de noms
MMO\core\classes
Implémente
JsonSerializable
A command documents itself in its attribute's info -- a string is its summary, as before: ```php fragment #[Command([['const' => 'cpam']], [ 'summary' => 'update the CPAMs from configs/cpams.json', //the recap's line 'description' => "What it does, what it writes, when to run it.\n\nA paragraph each.", 'options' => ['dry-run' => 'list, write nothing', 'database=<name>' => 'another database of the server', 'json|m' => 'json'], 'examples' => ['cpam --dry-run' => 'what would change'], //`php {script}` is added in front 'group' => 'CPAM', //the recap's section, else the package's name 'see' => ['cpam-orphans'], //related commands ])] ``` An option's key is how it is typed without its dashes: `dry-run` (a flag), `database=<name>` (with a value), `m` (a letter: `-m`), `json|m` (two spellings: `--json, -m`). The options are documentation only: what the command reads from the route is unchanged.
$manual = ShellManual::FromApplication('admin.php'); echo $manual->recap(); //every command, by group echo $manual->detail($manual->find('edms gc')); //the man page of `php admin.php edms gc` $manual->search('cpam'); //the commands about the cpams

Index

NAME_WIDTHthe widest a recap's command column gets: a longer name puts its summary on the next line
entries
info
script
add($entry)Add a command, unless one of the same name is already there.
detail($entry)The man page of $entry: its name and summary, how to type it, what it does, its arguments, its options, examples, related commands, and where it is declared.
Entry($command) staticThe documentation of one command, as FromApplication reads it from its attribute.
find($name)
FromApplication($script, $routes) staticThe manual of every shell command the application routes -- hidden ones, the interactive mode (index) and help itself left out, a command two controllers declare documented once (the first's, a…
getEntries()
getScript()
jsonSerialize()
line($name, $text, $indent, $column)$name then $text beside it in a column, wrapped with a hanging indent: the recap's line of a command, the detail's of an option.
markdown()The manual as a markdown page: a table of the commands by group, then the detail of each.
match($words)The command whose name is exactly $words, or that $words start with: cpam --help typed as help cpam extra.
Package($class) staticThe name of the package $class belongs to: the manifest of its longest namespace.
paragraph($text, $indent)$text wrapped to the manual's width, each line indented by $indent
recap($entries, $title)How to use the script, then every command (or $entries) by group, one line each.
search($text)The commands about $text: those whose name starts with it (edms gives every edms ...), else those whose name, group, summary, description or options hold it -- whatever the case.
Spelling($key) staticHow an option is typed, from its key in a command's options.
suggest($text, $max)The names closest to $text, for a command that does not exist.
synopsis($entry)How to type $entry: its words, its arguments, and its options when they are few ([options] when not).
typed($command)$command as typed: php {script} added in front of a command that does not start with php.
width()
__construct($script, $entries, $info)

Constantes1

NAME_WIDTH

the widest a recap's command column gets: a longer name puts its summary on the next line

const NAME_WIDTH = 30

Propriétés3

entries

protected array $entries = []
Type
array

info

protected array $info
Type
array

script

protected string $script
Type
string

Méthodes21

detail($entry)

ShellManual.php:393

The man page of $entry: its name and summary, how to type it, what it does, its arguments, its options, examples, related commands, and where it is declared.

function detail(array $entry): string
$entryarray
retournestring

Entry($command)

staticShellManual.php:74

The documentation of one command, as FromApplication reads it from its attribute.

static function Entry(MMO\core\attributes\APIRoute $command): ?array
$commandAPIRoute
retournenull | arraynull for a route that is not a command to list: not 'SHELL', hidden, index or help
ShellManual::Entry($route); // ['name' => 'edms gc', 'summary' => ..., 'options' => [['--dry-run', '...']], ...]

find($name)

ShellManual.php:214
function find(string $name): ?array
$namestringthe words of the command, as typed
retournenull | arrayits documentation
$manual->find('edms gc');

FromApplication($script, $routes)

staticShellManual.php:57

The manual of every shell command the application routes -- hidden ones, the interactive mode (index) and help itself left out, a command two controllers declare documented once (the first's, as the first claims it).

static function FromApplication(string $script, ?array $routes = null): MMO\core\classes\ShellManual
$scriptstring
$routes = nullnull | arraygroup => APIRoute[], defaults to the application's
retourneShellManual

jsonSerialize()

ShellManual.php:480
function jsonSerialize(): mixed
retournemixedthe script, the application's info and every command

line($name, $text, $indent, $column)

ShellManual.php:307

$name then $text beside it in a column, wrapped with a hanging indent: the recap's line of a command, the detail's of an option.

protected function line(string $name, string $text, int $indent, int $column): string
$namestringalready colored
$textstring
$indentint
$columnintwhere $text starts
retournestring

markdown()

ShellManual.php:437

The manual as a markdown page: a table of the commands by group, then the detail of each.

function markdown(): string
retournestring
file_put_contents('docs/commands.md', $manual->markdown()); // `php admin.php help --markdown=docs/commands.md`

match($words)

ShellManual.php:224

The command whose name is exactly $words, or that $words start with: cpam --help typed as help cpam extra.

function match(array $words): ?array
$wordsarray
retournenull | array

Package($class)

staticShellManual.php:179

The name of the package $class belongs to: the manifest of its longest namespace.

static function Package(string $class): ?string
$classstring
retournenull | string
ShellManual::Package(\MMO\edms\controllers\EdmsShellController::class) === 'mmo.edms'

paragraph($text, $indent)

ShellManual.php:282

$text wrapped to the manual's width, each line indented by $indent

protected function paragraph(string $text, int $indent): string
$textstring
$indentint
retournestring

recap($entries, $title)

ShellManual.php:356

How to use the script, then every command (or $entries) by group, one line each.

function recap(?array $entries = null, ?string $title = null): string
$entries = nullnull | arraythe commands to list, default every one
$title = nullnull | stringwhat the list is, above the groups
retournestring

Spelling($key)

staticShellManual.php:161

How an option is typed, from its key in a command's options.

static function Spelling(string $key): string
$keystring
retournestring
ShellManual::Spelling('json|m') === '--json, -m'ShellManual::Spelling('database=<name>') === '--database=<name>'

suggest($text, $max)

ShellManual.php:259

The names closest to $text, for a command that does not exist.

function suggest(string $text, int $max = 3): array
$textstring
$max = 3int
retournearray
$manual->suggest('cpma'); // ['cpam']

synopsis($entry)

ShellManual.php:329

How to type $entry: its words, its arguments, and its options when they are few ([options] when not).

function synopsis(array $entry): string
$entryarray
retournestring
`php admin.php token --username=<username>`

typed($command)

ShellManual.php:345

$command as typed: php {script} added in front of a command that does not start with php.

protected function typed(string $command): string
$commandstring
retournestring

width()

ShellManual.php:271
protected function width(): int
retourneintthe width the manual is wrapped to: the terminal's, between 60 and 120

__construct($script, $entries, $info)

ShellManual.php:46
function __construct(string $script, array $entries = [], array $info = [])
$scriptstringhow the commands are typed: php {script} ...
$entries = []arrayEntry's
$info = []arraytitle, description, version and icon of the application