Closed oscarotero closed 4 years ago
thank you for using library and opening a ticket. i will check it out sometime this weekend. (i thought it was already possible though)
i checked and it is working.
<?php
$app = new Ahc\Cli\Application('app', '0.0.1');
$app
->command('cmd', 'Some cmd')
->option('-o --option1', 'Some option')
->option('-O --option2', 'Some other option')
->action(function ($option1, $option2) {
var_dump($option1, $option2);
});
$app->handle($_SERVER['argv']);
$ php test.php cmd --option1 value1 --option2="value 2"
/mnt/d/projects/my/php-cli/test.php:9:
string(6) "value1"
/mnt/d/projects/my/php-cli/test.php:9:
string(7) "value 2"
Could you try updating adhocore/cli?
composer require adhocore/cli
latest release: https://github.com/adhocore/php-cli/releases/tag/0.8.0
Hi. Sorry but still not working to me. In my use case I have the following command:
php commands.php list --limit 5 --order-by "id desc"
Using =
I have the following error:
php commands.php list --limit 5 --order-by="id desc"
Ahc\Cli\Exception\RuntimeException Option "--order-by=id desc" not registered
(thrown in .../vendor/adhocore/cli/src/Input/Command.php:321)
thanks for example. could reproduce issue.
$ php commands.php list --limit 5 --order-by="id desc" # didnt work
$ php commands.php list --limit 5 --order="id desc" # worked
fixed in #55 (now both format above works)
Now works great. Thank you!
it would be interesting to know what you built using adhocore/cli
😎
It's just a cli tool to handle the database of a website (list, update, remove items, etc). I was looking for a simple tool to do something quick and easily. Symfony is a bit verbose in my opinion and your project is exactly what I need. (I used commander.js in other projects but in this case I needed something in PHP).
Again, thanks for create and maintain it.
Hi, thanks for this great library! I've noted that the parser does not support the ability to define arguments in this format:
But this works
I think this whould be a good adition because it's a common way to set option values. Thanks!