Command-Line Scripts
Usage Lines
Build a short usage line from a command name.
usage-line
Usage text can be built from small scalar pieces. Keeping it deterministic makes it suitable for static replay.
Usage Lines
usage_line.php
Replay: real traced execution (multi-file project)
<?php
$command = "run";
$usage = "php tool.php " . $command . " [options]";
$length = strlen($usage);
echo "command=" . $command . "\n";
echo "usage=" . $usage . "\n";
echo "length=" . $length . "\n";
<?php
$command = "check";
$usage = "php tool.php " . $command . " [options]";
$length = strlen($usage);
echo "command=" . $command . "\n";
echo "usage=" . $usage . "\n";
echo "length=" . $length . "\n";
<?php
$command = "deploy";
$usage = "php tool.php " . $command . " [options]";
$length = strlen($usage);
echo "command=" . $command . "\n";
echo "usage=" . $usage . "\n";
echo "length=" . $length . "\n";
$command ← run, $usage ← php tool.php run [options], $length ← 26
1<?php2$command→ run = "run"; //@command="check", "deploy"3$usage→ php tool.php run [options] = "php tool.php " . $commandrun . " [options]";4$length→ 26 = strlen($usagephp tool.php run [options]);56echo "command=" . $commandrun . "\n";7echo "usage=" . $usagephp tool.php run [options] . "\n";8echo "length=" . $length26 . "\n";outputcommand=run usage=php tool.php run [options] length=26
$command ← check, $usage ← php tool.php check [options], $length ← 28
1<?php2$command→ check = "check";3$usage→ php tool.php check [options] = "php tool.php " . $commandcheck . " [options]";4$length→ 28 = strlen($usagephp tool.php check [options]);56echo "command=" . $commandcheck . "\n";7echo "usage=" . $usagephp tool.php check [options] . "\n";8echo "length=" . $length28 . "\n";outputcommand=check usage=php tool.php check [options] length=28
$command ← deploy, $usage ← php tool.php deploy [options], $length ← 29
1<?php2$command→ deploy = "deploy";3$usage→ php tool.php deploy [options] = "php tool.php " . $commanddeploy . " [options]";4$length→ 29 = strlen($usagephp tool.php deploy [options]);56echo "command=" . $commanddeploy . "\n";7echo "usage=" . $usagephp tool.php deploy [options] . "\n";8echo "length=" . $length29 . "\n";outputcommand=deploy usage=php tool.php deploy [options] length=29