Command-Line Scripts
Subcommand Dispatch
Choose an action from a command name.
Subcommand Dispatch
subcommand_dispatch.php
<?php
$command = ;
$action = "compile";
if ($command === "test") {
$action = "verify";
} elseif ($command === "deploy") {
$action = "publish";
}
echo "command=" . $command . "\n";
echo "action=" . $action . "\n";
<?php
$command = ;
$action = "compile";
if ($command === "test") {
$action = "verify";
} elseif ($command === "deploy") {
$action = "publish";
}
echo "command=" . $command . "\n";
echo "action=" . $action . "\n";
<?php
$command = ;
$action = "compile";
if ($command === "test") {
$action = "verify";
} elseif ($command === "deploy") {
$action = "publish";
}
echo "command=" . $command . "\n";
echo "action=" . $action . "\n";
subcommand-dispatch
A command-line tool can route a subcommand to a specific action. The example uses local fixture data instead of real process arguments.