From 793e8830739f719351bb6da808916eac86014afe Mon Sep 17 00:00:00 2001 From: SanketDG Date: Fri, 8 May 2015 00:15:32 +0530 Subject: [PATCH 1/3] add man_no_space command --- thefuck/rules/man_no_space.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 thefuck/rules/man_no_space.py diff --git a/thefuck/rules/man_no_space.py b/thefuck/rules/man_no_space.py new file mode 100644 index 00000000..17513522 --- /dev/null +++ b/thefuck/rules/man_no_space.py @@ -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 From 65aeea857ef3e4934e25f5eb2675abe4520a7d77 Mon Sep 17 00:00:00 2001 From: SanketDG Date: Fri, 8 May 2015 00:15:57 +0530 Subject: [PATCH 2/3] add tests for man_no_space --- tests/rules/test_man_no_space.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/rules/test_man_no_space.py diff --git a/tests/rules/test_man_no_space.py b/tests/rules/test_man_no_space.py new file mode 100644 index 00000000..669ebb85 --- /dev/null +++ b/tests/rules/test_man_no_space.py @@ -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' From 045959ec47d8124e04a9e49f52cd79f109622968 Mon Sep 17 00:00:00 2001 From: SanketDG Date: Fri, 8 May 2015 00:16:50 +0530 Subject: [PATCH 3/3] add man_no_space --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ee52858f..4fb1bad8 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,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; @@ -193,13 +194,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 ```