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

Descriptions and default values #5

Merged
merged 3 commits into from
Feb 28, 2015
Merged

Conversation

mnapoli
Copy link
Owner

@mnapoli mnapoli commented Feb 14, 2015

This PR brings support to set descriptions and default values:

$app->command('greet firstname? lastname?', function () {
    // ...
});

$app->defaults('greet', [
    'firstname' => 'John',
    'lastname'  => 'Doe',
]);

$app->descriptions('greet', 'Greet someone', [
    'name'   => 'Who do you want to greet?',
    '--yell' => 'If set, the task will yell in uppercase letters',
]);

@mnapoli mnapoli mentioned this pull request Feb 14, 2015
@mnapoli mnapoli added this to the 1.0 milestone Feb 15, 2015
@brandisher
Copy link

@mnapoli Thanks for looking into the defaults and descriptions, they'll be a big improvement. I do think that there should be a more fluid way to add them. Descriptions would almost always be necessary, so I think either defining them as a parameter in the command() call or as a chained method would make the most sense.

With defaults, I think a chained method makes the most sense.

Both descriptions and defaults are tied directly to the command so I think method chaining is the best methodology for both. I'd be happy to assist if need be. My time is sort of limited but I really like the style of this project, kind of like Slim for cli :-)

@mnapoli
Copy link
Owner Author

mnapoli commented Feb 16, 2015

@cwscribner so with the same example that would be:

$app->command('greet firstname? lastname?', function () {
    // ...
})->defaults([
    'firstname' => 'John',
    'lastname'  => 'Doe',
])->descriptions('Greet someone', [
    'name'   => 'Who do you want to greet?',
    '--yell' => 'If set, the task will yell in uppercase letters',
]);

Is that what you had in mind?

@brandisher
Copy link

Precisely! I definitely like the descriptions() parameter organization. Since it's called as a chained method, it totally makes sense for the function signature to be descriptions(string $commandDescription, array $parameterDescripitions). Very clean :-)

@mnapoli
Copy link
Owner Author

mnapoli commented Feb 16, 2015

OK that's fine by me, I'll try to update my PR when I have time (going on holidays soon ;))

@mnapoli
Copy link
Owner Author

mnapoli commented Feb 28, 2015

All done, @cwscribner syntax updated with the fluent interface.

mnapoli added a commit that referenced this pull request Feb 28, 2015
@mnapoli mnapoli merged commit b2940ad into master Feb 28, 2015
@mnapoli mnapoli deleted the descriptions-and-default-values branch February 28, 2015 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants