mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-20 11:58:52 +00:00
Add support of lein
"is not task"
This commit is contained in:
parent
3440582494
commit
8b2ba5762c
11
README.md
11
README.md
@ -49,6 +49,17 @@ Did you mean this?
|
||||
➜ fuck
|
||||
git branch
|
||||
* master
|
||||
|
||||
➜ lein rpl
|
||||
'rpl' is not a task. See 'lein help'.
|
||||
|
||||
Did you mean this?
|
||||
repl
|
||||
|
||||
➜ fuck
|
||||
nREPL server started on port 54848 on host 127.0.0.1 - nrepl://127.0.0.1:54848
|
||||
REPL-y 0.3.1
|
||||
...
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
||||
|
||||
|
||||
setup(name='thefuck',
|
||||
version=1.11,
|
||||
version=1.12,
|
||||
description="Magnificent app which corrects your previous console command",
|
||||
author='Vladimir Iakovlev',
|
||||
author_email='nvbn.rm@gmail.com',
|
||||
|
22
tests/rules/test_lein_not_task.py
Normal file
22
tests/rules/test_lein_not_task.py
Normal file
@ -0,0 +1,22 @@
|
||||
import pytest
|
||||
from mock import Mock
|
||||
from thefuck.rules.lein_not_task import match, get_new_command
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def is_not_task():
|
||||
return ''''rpl' is not a task. See 'lein help'.
|
||||
|
||||
Did you mean this?
|
||||
repl
|
||||
'''
|
||||
|
||||
|
||||
def test_match(is_not_task):
|
||||
assert match(Mock(script='lein rpl', stderr=is_not_task), None)
|
||||
assert not match(Mock(script='ls', stderr=is_not_task), None)
|
||||
|
||||
|
||||
def test_get_new_command(is_not_task):
|
||||
assert get_new_command(Mock(script='lein rpl --help', stderr=is_not_task),
|
||||
None) == 'lein repl --help'
|
15
thefuck/rules/lein_not_task.py
Normal file
15
thefuck/rules/lein_not_task.py
Normal file
@ -0,0 +1,15 @@
|
||||
import re
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
return (command.script.startswith('lein')
|
||||
and "is not a task. See 'lein help'" in command.stderr
|
||||
and 'Did you mean this?' in command.stderr)
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
broken_cmd = re.findall(r"'([^']*)' is not a task",
|
||||
command.stderr)[0]
|
||||
new_cmd = re.findall(r'Did you mean this\?\n\s*([^\n]*)',
|
||||
command.stderr)[0]
|
||||
return command.script.replace(broken_cmd, new_cmd, 1)
|
Loading…
x
Reference in New Issue
Block a user