commando
commando copied to clipboard
--help "Could not find the specified path"
--help command gives me Could not find the specified path.
PHP code:
<?php
require_once 'vendor/autoload.php';
use Commando\Command;
// command config
$cmd = new Command;
$cmd
->setHelp('This is a great command it. It can be used by calling `run <argument>`.')
->option()->referToAs('the first arg')->describeAs('run takes an optional single argument. e.g. run argument0')
->option('a')->description("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.")
->option('b')->boolean()->describeAs("A boolean option.")
->option('c')->aka('foo')->describeAs("Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt.")->required();
Output:
C:\Users\MYUSER\Desktop\myscript>php index.php --help
Could not find the specified path.
Could not find the specified path.
Could not find the specified path.
Could not find the specified path.
Could not find the specified path.
Could not find the specified path.
Could not find the specified path.
index.php
This is a great command it. It can be used by calling `run <argument>`.
the first arg
run takes an optional single argument. e.g. run argument0
-a <argument>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur.
-b
A boolean option.
-c/--foo <argument>
Required. Excepteur sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt.
--help
Show the help page for this command.
composer.json:
{
"name": "my/my",
"description": "my",
"require": {
"nategood/commando": "^0.2.9"
},
"authors": [
{
"name": "me",
"email": "[email protected]"
}
]
}
I am on Windows
Confirm that the issue is a bug here: https://github.com/nategood/commando/blob/ba476a3928dcecfb257f9daf7d965a3abe53b6bd/src/Commando/Util/Terminal.php#L53
And this should be solved with the following patch:
diff --git a/src/Commando/Util/Terminal.php b/src/Commando/Util/Terminal.php
index ff49888..5b252d8 100644
--- a/src/Commando/Util/Terminal.php
+++ b/src/Commando/Util/Terminal.php
@@ -50,6 +50,17 @@ class Terminal
*/
private static function tput($default, $param = 'cols')
{
+ if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
+ $test = shell_exec('mode con');
+ if (empty($test))
+ return $default;
+ $result = explode(':', $test);
+ $lines = (int)$result[2];
+ $cols = (int)$result[3];
+ if ('lines' === $param) return $lines;
+ if ('cols' === $param) return $cols;
+ }
+
$test = exec('tput ' . $param . ' 2>/dev/null');
if (empty($test))
return $default;
I can confirm that this does indeed fix the issue.