Skip to content

Commit 9222ff4

Browse files
committed
Fix shell type detection.
1 parent c4d7245 commit 9222ff4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/CompletionCommand.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,20 @@ protected function configure()
3333
->addOption(
3434
'generate-hook',
3535
'g',
36-
InputOption::VALUE_OPTIONAL,
36+
InputOption::VALUE_NONE,
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-type',
47+
null,
48+
InputOption::VALUE_OPTIONAL,
49+
'Set the shell type (zsh or bash). Otherwise this is determined automatically.'
4450
);
4551
}
4652

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

5662
$factory = new HookFactory();
5763
$hook = $factory->generateHook(
58-
$input->getOption('generate-hook') ?: $this->getShellType(),
64+
$input->getOption('shell-type') ?: $this->getShellType(),
5965
$program,
6066
$input->getOption('program')
6167
);
@@ -79,10 +85,10 @@ protected function runCompletion()
7985
protected function getShellType()
8086
{
8187
if (!getenv('SHELL')) {
82-
throw new \RuntimeException('Could not read SHELL environment variable. Please specify your shell type as an argument to the --generate-hook option.');
88+
throw new \RuntimeException('Could not read SHELL environment variable. Please specify your shell type using the --shell-type option.');
8389
}
8490

85-
return basename(realpath(getenv('SHELL')));
91+
return basename(getenv('SHELL'));
8692
}
8793

8894
}

0 commit comments

Comments
 (0)