mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 20:11:17 +00:00
Merge pull request #170 from SanketDG/manfix
add rule for having no spaces in man commands.
This commit is contained in:
commit
1bed4d4e8d
@ -153,6 +153,7 @@ using matched rule and run it. Rules enabled by default:
|
||||
* `lein_not_task` – fixes wrong `lein` tasks like `lein rpl`;
|
||||
* `mkdir_p` – adds `-p` when you trying to create directory without parent;
|
||||
* `no_command` – fixes wrong console commands, for example `vom/vim`;
|
||||
* `man_no_space` – fixes man commands without spaces, for example `mandiff`;
|
||||
* `pacman` – installs app with `pacman` or `yaourt` if it is not installed;
|
||||
* `pip_unknown_command` – fixes wrong pip commands, for example `pip instatl/pip install`;
|
||||
* `python_command` – prepends `python` when you trying to run not executable/without `./` python script;
|
||||
@ -194,13 +195,13 @@ def match(command, settings):
|
||||
|
||||
def get_new_command(command, settings):
|
||||
return 'sudo {}'.format(command.script)
|
||||
|
||||
|
||||
# Optional:
|
||||
enabled_by_default = True
|
||||
|
||||
def side_effect(command, settings):
|
||||
subprocess.call('chmod 777 .', shell=True)
|
||||
|
||||
|
||||
priority = 1000 # Lower first
|
||||
```
|
||||
|
||||
|
12
tests/rules/test_man_no_space.py
Normal file
12
tests/rules/test_man_no_space.py
Normal file
@ -0,0 +1,12 @@
|
||||
from thefuck.rules.man_no_space import match, get_new_command
|
||||
from tests.utils import Command
|
||||
|
||||
|
||||
def test_match():
|
||||
assert match(Command('mandiff', stderr='mandiff: command not found'), None)
|
||||
assert not match(Command(), None)
|
||||
|
||||
|
||||
def test_get_new_command():
|
||||
assert get_new_command(
|
||||
Command('mandiff'), None) == 'man diff'
|
9
thefuck/rules/man_no_space.py
Normal file
9
thefuck/rules/man_no_space.py
Normal file
@ -0,0 +1,9 @@
|
||||
def match(command, settings):
|
||||
return (command.script.startswith(u'man')
|
||||
and u'command not found' in command.stderr.lower())
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
return u'man {}'.format(command.script[3:])
|
||||
|
||||
priority = 2000
|
Loading…
x
Reference in New Issue
Block a user