-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Default values for options #21
Comments
I'm invoking the CLI application with |
Thanks for the report. I had a closer look and it's possible to set default values only for arguments (not for options): https://github.com/mnapoli/silly/blob/master/src/Command/Command.php#L36 At first I thought it was a bug but it's simply not implemented. Maybe we could add support for that, the question is what would be the best way for it? $cli->command('foo [--bar=]', function($bar) {
// ...
})->defaults([
'--bar' => 'baz',
]); maybe? (to differentiate from argument default values) Or we could also maybe have a look at the default value of the closure parameter, e.g. $cli->command('foo [--bar=]', function($bar = 'baz') {
// ...
}); That could maybe work for arguments too, I don't remember if there was a reason why we didn't go this way at all for arguments default values. |
Thanks for the reply @mnapoli. I think your suggestion of I haven't done much with the Reflection API, or PHP-DI, so I don't know of any technical limitations why using an argument's default value would not work, i.e. |
Fixed in #25 |
I cannot seem to supply a default value to an option which accepts a value. Let me know if I'm misunderstanding the command definition API.
I've tried within the anonymous function's parameter definition:
And also with the
->defaults()
method:PHP 7.0.7, OS X 10.11.3, silly v1.3.0
Thanks!
The text was updated successfully, but these errors were encountered: