mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-20 20:09:07 +00:00
Merge pull request #562 from josephfrazier/man-help
Suggest `foo --help` when `man foo` shows no pages
This commit is contained in:
commit
02f717a0e8
@ -23,7 +23,8 @@ def test_not_match(command):
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command, new_command', [
|
||||
(Command('man read'), ['man 3 read', 'man 2 read']),
|
||||
(Command('man read'), ['man 3 read', 'man 2 read', 'read --help']),
|
||||
(Command('man missing', stderr="No manual entry for missing\n"), ['missing --help']),
|
||||
(Command('man 2 read'), 'man 3 read'),
|
||||
(Command('man 3 read'), 'man 2 read'),
|
||||
(Command('man -s2 read'), 'man -s3 read'),
|
||||
|
@ -12,10 +12,22 @@ def get_new_command(command):
|
||||
if '2' in command.script:
|
||||
return command.script.replace("2", "3")
|
||||
|
||||
last_arg = command.script_parts[-1]
|
||||
help_command = last_arg + ' --help'
|
||||
|
||||
# If there are no man pages for last_arg, suggest `last_arg --help` instead.
|
||||
# Otherwise, suggest `--help` after suggesting other man page sections.
|
||||
if command.stderr.strip() == 'No manual entry for ' + last_arg:
|
||||
return [help_command]
|
||||
|
||||
split_cmd2 = command.script_parts
|
||||
split_cmd3 = split_cmd2[:]
|
||||
|
||||
split_cmd2.insert(1, ' 2 ')
|
||||
split_cmd3.insert(1, ' 3 ')
|
||||
|
||||
return ["".join(split_cmd3), "".join(split_cmd2)]
|
||||
return [
|
||||
"".join(split_cmd3),
|
||||
"".join(split_cmd2),
|
||||
help_command,
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user