Application
in package
Dependency-free command-line interface for common parser workflows.
Table of Contents
Methods
- run() : int
- Run the CLI application.
- assets() : int
- Output referenced assets as JSON.
- diff() : int
- Compare two projects semantically.
- extract() : int
- Extract a project.
- fingerprint() : int
- Output exact and normalized fingerprints.
- help() : int
- Show CLI usage.
- inspect() : int
- Inspect lightweight project metadata.
- json() : int
- Output parser JSON.
- manifest() : int
- Output the package manifest as JSON.
- removeFlag() : bool
- Remove a boolean flag from arguments.
- requiredArgument() : string|null
- Return a required positional argument.
- unknownCommand() : int
- Handle unknown commands.
- validate() : int
- Validate a project.
- write() : void
- Write to a stream.
- writeJson() : void
- Write pretty JSON.
Methods
run()
Run the CLI application.
public
run(array<int, string> $argv[, resource|null $stdout = null ][, resource|null $stderr = null ]) : int
Parameters
- $argv : array<int, string>
-
Command-line arguments.
- $stdout : resource|null = null
-
Output stream.
- $stderr : resource|null = null
-
Error stream.
Return values
int —Process exit code.
assets()
Output referenced assets as JSON.
private
assets(array<int, string> $arguments, resource $stdout, resource $stderr) : int
Parameters
- $arguments : array<int, string>
-
Command arguments.
- $stdout : resource
-
Output stream.
- $stderr : resource
-
Error stream.
Return values
intdiff()
Compare two projects semantically.
private
diff(array<int, string> $arguments, resource $stdout, resource $stderr) : int
Parameters
- $arguments : array<int, string>
-
Command arguments.
- $stdout : resource
-
Output stream.
- $stderr : resource
-
Error stream.
Return values
intextract()
Extract a project.
private
extract(array<int, string> $arguments, resource $stdout, resource $stderr) : int
Parameters
- $arguments : array<int, string>
-
Command arguments.
- $stdout : resource
-
Output stream.
- $stderr : resource
-
Error stream.
Return values
intfingerprint()
Output exact and normalized fingerprints.
private
fingerprint(array<int, string> $arguments, bool $json, resource $stdout, resource $stderr) : int
Parameters
- $arguments : array<int, string>
-
Command arguments.
- $json : bool
-
Output JSON.
- $stdout : resource
-
Output stream.
- $stderr : resource
-
Error stream.
Return values
inthelp()
Show CLI usage.
private
help(resource $stdout) : int
Parameters
- $stdout : resource
-
Output stream.
Return values
intinspect()
Inspect lightweight project metadata.
private
inspect(array<int, string> $arguments, bool $json, resource $stdout, resource $stderr) : int
Parameters
- $arguments : array<int, string>
-
Command arguments.
- $json : bool
-
Output JSON.
- $stdout : resource
-
Output stream.
- $stderr : resource
-
Error stream.
Return values
intjson()
Output parser JSON.
private
json(array<int, string> $arguments, bool $detailed, resource $stdout, resource $stderr) : int
Parameters
- $arguments : array<int, string>
-
Command arguments.
- $detailed : bool
-
Use detailed representation.
- $stdout : resource
-
Output stream.
- $stderr : resource
-
Error stream.
Return values
intmanifest()
Output the package manifest as JSON.
private
manifest(array<int, string> $arguments, resource $stdout, resource $stderr) : int
Parameters
- $arguments : array<int, string>
-
Command arguments.
- $stdout : resource
-
Output stream.
- $stderr : resource
-
Error stream.
Return values
intremoveFlag()
Remove a boolean flag from arguments.
private
removeFlag(array<int, string> &$arguments, string $flag) : bool
Parameters
- $arguments : array<int, string>
-
Arguments.
- $flag : string
-
Flag to remove.
Return values
boolrequiredArgument()
Return a required positional argument.
private
requiredArgument(array<int, string> $arguments, int $index, string $message, resource $stderr) : string|null
Parameters
- $arguments : array<int, string>
-
Arguments.
- $index : int
-
Argument index.
- $message : string
-
Error message.
- $stderr : resource
-
Error stream.
Return values
string|nullunknownCommand()
Handle unknown commands.
private
unknownCommand(string $command, resource $stderr) : int
Parameters
- $command : string
-
Unknown command.
- $stderr : resource
-
Error stream.
Return values
intvalidate()
Validate a project.
private
validate(array<int, string> $arguments, bool $json, resource $stdout, resource $stderr) : int
Parameters
- $arguments : array<int, string>
-
Command arguments.
- $json : bool
-
Output JSON.
- $stdout : resource
-
Output stream.
- $stderr : resource
-
Error stream.
Return values
intwrite()
Write to a stream.
private
write(resource $stream, string $text) : void
Parameters
- $stream : resource
-
Output stream.
- $text : string
-
Text to write.
writeJson()
Write pretty JSON.
private
writeJson(resource $stream, mixed $value) : void
Parameters
- $stream : resource
-
Output stream.
- $value : mixed
-
Value to encode.