Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--help "Could not find the specified path" #78

Open
cirolaferrara opened this issue Oct 5, 2017 · 2 comments
Open

--help "Could not find the specified path" #78

cirolaferrara opened this issue Oct 5, 2017 · 2 comments

Comments

@cirolaferrara
Copy link

cirolaferrara commented Oct 5, 2017

--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

@mingtsay
Copy link

Confirm that the issue is a bug here:

$test = exec('tput ' . $param . ' 2>/dev/null');

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;

@aalaap
Copy link

aalaap commented Aug 20, 2018

I can confirm that this does indeed fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants