mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
#351 Speed-up mvn rules, pep8 fixes
This commit is contained in:
parent
9103c1ffd5
commit
f2a7364e8c
@ -1,8 +1,11 @@
|
|||||||
from thefuck import shells
|
from thefuck.utils import for_app
|
||||||
|
|
||||||
|
|
||||||
|
@for_app('mvn')
|
||||||
def match(command, settings):
|
def match(command, settings):
|
||||||
return 'No goals have been specified for this build' in command.stdout and command.script.startswith('mvn')
|
return 'No goals have been specified for this build' in command.stdout
|
||||||
|
|
||||||
|
|
||||||
def get_new_command(command, settings):
|
def get_new_command(command, settings):
|
||||||
return [ command.script + ' clean package', command.script + ' clean install']
|
return [command.script + ' clean package',
|
||||||
|
command.script + ' clean install']
|
||||||
|
@ -1,20 +1,32 @@
|
|||||||
from thefuck import shells
|
from thefuck.utils import replace_command, for_app
|
||||||
from thefuck.utils import replace_command
|
|
||||||
from difflib import get_close_matches
|
from difflib import get_close_matches
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def _get_failed_lifecycle(command):
|
||||||
|
return re.search(r'\[ERROR\] Unknown lifecycle phase "(.+)"',
|
||||||
|
command.stdout)
|
||||||
|
|
||||||
|
|
||||||
|
def _getavailable_lifecycles(command):
|
||||||
|
return re.search(
|
||||||
|
r'Available lifecycle phases are: (.+) -> \[Help 1\]', command.stdout)
|
||||||
|
|
||||||
|
|
||||||
|
@for_app('mvn')
|
||||||
def match(command, settings):
|
def match(command, settings):
|
||||||
failedLifecycle = re.search('\[ERROR\] Unknown lifecycle phase "(.+)"', command.stdout)
|
failed_lifecycle = _get_failed_lifecycle(command)
|
||||||
availableLifecycles = re.search('Available lifecycle phases are: (.+) -> \[Help 1\]', command.stdout)
|
available_lifecycles = _getavailable_lifecycles(command)
|
||||||
return availableLifecycles and failedLifecycle and command.script.startswith('mvn')
|
return available_lifecycles and failed_lifecycle
|
||||||
|
|
||||||
|
|
||||||
def get_new_command(command, settings):
|
def get_new_command(command, settings):
|
||||||
failedLifecycle = re.search('\[ERROR\] Unknown lifecycle phase "(.+)"', command.stdout)
|
failed_lifecycle = _get_failed_lifecycle(command)
|
||||||
availableLifecycles = re.search('Available lifecycle phases are: (.+) -> \[Help 1\]', command.stdout)
|
available_lifecycles = _getavailable_lifecycles(command)
|
||||||
if availableLifecycles and failedLifecycle:
|
if available_lifecycles and failed_lifecycle:
|
||||||
selectedLifecycle = get_close_matches(failedLifecycle.group(1), availableLifecycles.group(1).split(", "), 3, 0.6)
|
selected_lifecycle = get_close_matches(
|
||||||
return replace_command(command, failedLifecycle.group(1), selectedLifecycle)
|
failed_lifecycle.group(1), available_lifecycles.group(1).split(", "),
|
||||||
|
3, 0.6)
|
||||||
|
return replace_command(command, failed_lifecycle.group(1), selected_lifecycle)
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
@ -138,7 +138,8 @@ def replace_command(command, broken, matched):
|
|||||||
def is_app(command, *app_names):
|
def is_app(command, *app_names):
|
||||||
"""Returns `True` if command is call to one of passed app names."""
|
"""Returns `True` if command is call to one of passed app names."""
|
||||||
for name in app_names:
|
for name in app_names:
|
||||||
if command.script.startswith(u'{} '.format(name)):
|
if command.script == name \
|
||||||
|
or command.script.startswith(u'{} '.format(name)):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user