Skip to content

Commit bbda3f3

Browse files
committed
Rework --shell option into --generate-hook to avoid option conflict
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
1 parent 365be6b commit bbda3f3

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/CompletionCommand.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,14 @@ protected function configure()
3333
->addOption(
3434
'generate-hook',
3535
'g',
36-
InputOption::VALUE_NONE,
36+
InputOption::VALUE_OPTIONAL,
3737
'Generate BASH code that sets up completion for this application.'
3838
)
3939
->addOption(
4040
'program',
4141
'p',
4242
InputOption::VALUE_REQUIRED,
4343
"Program name that should trigger completion\n<comment>(defaults to the absolute application path)</comment>."
44-
)
45-
->addOption(
46-
'shell',
47-
's',
48-
InputOption::VALUE_REQUIRED,
49-
"Force the shell to generate a hook for <comment>(" . implode(', ', HookFactory::getShellTypes()) . ")</comment>\n"
5044
);
5145
}
5246

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

6256
$factory = new HookFactory();
6357
$hook = $factory->generateHook(
64-
$input->getOption('shell') ?: $this->getShellType(),
58+
$input->getOption('generate-hook') ?: $this->getShellType(),
6559
$program,
6660
$input->getOption('program')
6761
);
@@ -85,7 +79,7 @@ protected function runCompletion()
8579
protected function getShellType()
8680
{
8781
if (!getenv('SHELL')) {
88-
throw new \RuntimeException('Could not read SHELL environment variable. Please specify your shell type with the --shell option');
82+
throw new \RuntimeException('Could not read SHELL environment variable. Please specify your shell type as an argument to the --generate-hook option.');
8983
}
9084

9185
return basename(realpath(getenv('SHELL')));

0 commit comments

Comments
 (0)