clue / commander

Finally a sane way to register available commands and arguments and match your command line in PHP
MIT License
169 stars 8 forks source link

Add description text to Route #18

Open davidwdan opened 8 years ago

davidwdan commented 8 years ago

It would be nice to have the ability to add some optional description text to a route.

Something like:

$router->add('test', function () {
    //do something
})->addDescription('This is a description');

OR

$router->add('test', function () {
    //do something
}, 'This is a description');
clue commented 8 years ago

Thanks for opening this ticket :+1: I understand where you're coming from as I have faced the same issue when integrating this into some bigger projects.

I'm currently undecided because I'm not sure what the best interface would look like, given we don't really work with these texts, unlike for example Symfony Console. Do we need a "description", "short text", "long text" etc.?

In the meantime, I've applied the following workaround when I integrated this into another project: https://github.com/clue/psocksd/blob/a922d8beeff7b98a99ac50e910cd95b60a318218/src/Command/Via.php#L25 PHP allows you to set arbitrary additional public properties, so these can be used to attach any kind of information you need. (Note I'm not saying this is the best solution, but it kind of works for now)

I'd love to hear some more thoughts on this :+1:

davidwdan commented 8 years ago

I think that the solution you suggested will work for my purposes.