25142f81f8
* #833: do not require sudo on TravisCI * #N/A: Add Python dev releases to TravisCI pipeline Inspired by Brett Cannon's advise [1]. 1: https://snarky.ca/how-to-use-your-project-travis-to-help-test-python-itself/ * #837: try and kill proc and its children * #N/A: show shell information on `thefuck --version` * #N/A: omit default arguments to get_close_matches * #842: add settings var to control number of close matches * #N/A: remove `n` from the list of `get_closest`'s args
31 lines
1011 B
Python
31 lines
1011 B
Python
from thefuck.utils import for_app, get_close_matches, replace_command
|
|
import re
|
|
|
|
|
|
def _get_failed_lifecycle(command):
|
|
return re.search(r'\[ERROR\] Unknown lifecycle phase "(.+)"',
|
|
command.output)
|
|
|
|
|
|
def _getavailable_lifecycles(command):
|
|
return re.search(
|
|
r'Available lifecycle phases are: (.+) -> \[Help 1\]', command.output)
|
|
|
|
|
|
@for_app('mvn')
|
|
def match(command):
|
|
failed_lifecycle = _get_failed_lifecycle(command)
|
|
available_lifecycles = _getavailable_lifecycles(command)
|
|
return available_lifecycles and failed_lifecycle
|
|
|
|
|
|
def get_new_command(command):
|
|
failed_lifecycle = _get_failed_lifecycle(command)
|
|
available_lifecycles = _getavailable_lifecycles(command)
|
|
if available_lifecycles and failed_lifecycle:
|
|
selected_lifecycle = get_close_matches(
|
|
failed_lifecycle.group(1), available_lifecycles.group(1).split(", "))
|
|
return replace_command(command, failed_lifecycle.group(1), selected_lifecycle)
|
|
else:
|
|
return []
|