auraphp / Aura.Cli_Project

The skeleton for a CLI project.
BSD 2-Clause "Simplified" License
14 stars 2 forks source link

question pmjones #8

Closed cordoval closed 10 years ago

cordoval commented 10 years ago
$help = $di->newInstance('Aura\Cli\Help');

besides creating a new instance of the Help, i wonder if this should be pushed to the di with a service id that is distinguishable besides being passed just in the use () of the callback. Do you follow what I am trying to ask? it just feels weird.

cordoval commented 10 years ago

@pmjones @harikt bang bang! :blush:

harikt commented 10 years ago

@cordoval not sure I get you.

I am looking at the example and trying to figure out

$help_service = $di->get('aura/cli-kernel:help_service');
$help = $di->newInstance('Aura\Cli\Help');
$help_service->set('hello', function () use ($help) {
    $help->setUsage(array('', '<noun>'));
    $help->setSummary("A demonstration 'hello world' command.");
    return $help;
});

Is your question is like setting Aura\Cli\Help as a service

$di->set('aura/cli-kernel:help', $di->newInstance('Aura\Cli\Help'));

and use

$help_service = $di->get('aura/cli-kernel:help_service');
$help = $di->get('aura/cli-kernel:help');
$help_service->set('hello', function () use ($help) {
    $help->setUsage(array('', '<noun>'));
    $help->setSummary("A demonstration 'hello world' command.");
    return $help;
});
cordoval commented 10 years ago

right exactly, it seems to me it is more proper

cordoval commented 10 years ago

should I send a PR?

harikt commented 10 years ago

@cordoval you can send PR.

Just remember the final word you should hear is from @pmjones .

Thank you.

cordoval commented 10 years ago

yeah i know, I just want to voice my concerns :blush: nothing harsh or personal, just going through some code reading, you guys caught once again my attention.

pmjones commented 10 years ago

The Help instance should not be a shared service; it has to be a instance separate from every other Help instance. (Each Help instance is specific to the command it is a Help for.) Hope that makes sense.

cordoval commented 10 years ago

same argument as the other issue, not here, but sometimes you want to share helpers, this occurs massively in other projects, such as phpcr, gush, etc.

pmjones commented 10 years ago

This is not a "helper" of that kind. It is a way of describing the help output when you ask for help about a command at the command line.

cordoval commented 10 years ago

oh true, my bad, terminology is killing me :+1:

cordoval commented 10 years ago

yeah totally, i was looking through the things via symfony glasses, I need to think outside the box :+1: :eyeglasses: :arrow_forward: :eyes: