Skip to content

Commit

Permalink
Rework --shell option into --generate-hook to avoid option conflict
Browse files Browse the repository at this point in the history
The Symfony Framework console has a global --shell option which makes 0.4.0
of this module incompatible with it. Conflicts can't be avoided with everything,
but since use with Symphony Framework is one of the main use cases for this
module, it's worth avoiding a conflict.

Resolves #6
  • Loading branch information
stecman committed Oct 21, 2014
1 parent 365be6b commit bbda3f3
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/CompletionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,14 @@ protected function configure()
->addOption(
'generate-hook',
'g',
InputOption::VALUE_NONE,
InputOption::VALUE_OPTIONAL,
'Generate BASH code that sets up completion for this application.'
)
->addOption(
'program',
'p',
InputOption::VALUE_REQUIRED,
"Program name that should trigger completion\n<comment>(defaults to the absolute application path)</comment>."
)
->addOption(
'shell',
's',
InputOption::VALUE_REQUIRED,
"Force the shell to generate a hook for <comment>(" . implode(', ', HookFactory::getShellTypes()) . ")</comment>\n"
);
}

Expand All @@ -61,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$factory = new HookFactory();
$hook = $factory->generateHook(
$input->getOption('shell') ?: $this->getShellType(),
$input->getOption('generate-hook') ?: $this->getShellType(),
$program,
$input->getOption('program')
);
Expand All @@ -85,7 +79,7 @@ protected function runCompletion()
protected function getShellType()
{
if (!getenv('SHELL')) {
throw new \RuntimeException('Could not read SHELL environment variable. Please specify your shell type with the --shell option');
throw new \RuntimeException('Could not read SHELL environment variable. Please specify your shell type as an argument to the --generate-hook option.');
}

return basename(realpath(getenv('SHELL')));
Expand Down

0 comments on commit bbda3f3

Please sign in to comment.