mirror of
https://github.com/nvbn/thefuck.git
synced 2025-11-12 12:55:58 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c88b0792b8 | ||
|
|
06a89427e2 | ||
|
|
3a134f250d | ||
|
|
b54cdf7c49 | ||
|
|
1b05a497e8 | ||
|
|
79602383ec | ||
|
|
84c42168df | ||
|
|
f53d772ac3 | ||
|
|
93d4a4fc3a | ||
|
|
2cb23b1805 | ||
|
|
33f28cf76d | ||
|
|
6322dbd9ed |
@@ -429,9 +429,9 @@ Project License can be found [here](LICENSE.md).
|
|||||||
|
|
||||||
[version-badge]: https://img.shields.io/pypi/v/thefuck.svg?label=version
|
[version-badge]: https://img.shields.io/pypi/v/thefuck.svg?label=version
|
||||||
[version-link]: https://pypi.python.org/pypi/thefuck/
|
[version-link]: https://pypi.python.org/pypi/thefuck/
|
||||||
[travis-badge]: https://img.shields.io/travis/nvbn/thefuck.svg
|
[travis-badge]: https://travis-ci.org/nvbn/thefuck.svg?branch=master
|
||||||
[travis-link]: https://travis-ci.org/nvbn/thefuck
|
[travis-link]: https://travis-ci.org/nvbn/thefuck
|
||||||
[appveyor-badge]: https://img.shields.io/appveyor/ci/nvbn/thefuck.svg?label=windows%20build
|
[appveyor-badge]: https://ci.appveyor.com/api/projects/status/1sskj4imj02um0gu/branch/master?svg=true
|
||||||
[appveyor-link]: https://ci.appveyor.com/project/nvbn/thefuck
|
[appveyor-link]: https://ci.appveyor.com/project/nvbn/thefuck
|
||||||
[coverage-badge]: https://img.shields.io/coveralls/nvbn/thefuck.svg
|
[coverage-badge]: https://img.shields.io/coveralls/nvbn/thefuck.svg
|
||||||
[coverage-link]: https://coveralls.io/github/nvbn/thefuck
|
[coverage-link]: https://coveralls.io/github/nvbn/thefuck
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -29,7 +29,7 @@ elif (3, 0) < version < (3, 3):
|
|||||||
' ({}.{} detected).'.format(*version))
|
' ({}.{} detected).'.format(*version))
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
VERSION = '3.16'
|
VERSION = '3.18'
|
||||||
|
|
||||||
install_requires = ['psutil', 'colorama', 'six', 'decorator']
|
install_requires = ['psutil', 'colorama', 'six', 'decorator']
|
||||||
extras_require = {':python_version<"3.4"': ['pathlib2'],
|
extras_require = {':python_version<"3.4"': ['pathlib2'],
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ shells.shell = shells.Generic()
|
|||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
"""Adds `--run-without-docker` argument."""
|
"""Adds `--enable-functional` argument."""
|
||||||
group = parser.getgroup("thefuck")
|
group = parser.getgroup("thefuck")
|
||||||
group.addoption('--enable-functional', action="store_true", default=False,
|
group.addoption('--enable-functional', action="store_true", default=False,
|
||||||
help="Enable functional tests")
|
help="Enable functional tests")
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def test_match(script):
|
|||||||
assert match(Command(script))
|
assert match(Command(script))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('script', ['git branch' 'vimfile'])
|
@pytest.mark.parametrize('script', ['git branch', 'vimfile'])
|
||||||
def test_not_match(script):
|
def test_not_match(script):
|
||||||
assert not match(Command(script))
|
assert not match(Command(script))
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,13 @@ def test_not_match(command):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command, result', [
|
@pytest.mark.parametrize('command, result', [
|
||||||
(Command('yarn whyy webpack', stderr=stderr('whyy')), 'yarn why webpack')])
|
(Command('yarn whyy webpack', stderr=stderr('whyy')),
|
||||||
|
'yarn why webpack'),
|
||||||
|
(Command('yarn require lodash', stderr=stderr('require')),
|
||||||
|
'yarn add lodash')])
|
||||||
def test_get_new_command(command, result):
|
def test_get_new_command(command, result):
|
||||||
assert get_new_command(command)[0] == result
|
fixed_command = get_new_command(command)
|
||||||
|
if isinstance(fixed_command, list):
|
||||||
|
fixed_command = fixed_command[0]
|
||||||
|
|
||||||
|
assert fixed_command == result
|
||||||
|
|||||||
@@ -125,5 +125,5 @@ def configured_successfully(configuration_details):
|
|||||||
|
|
||||||
def version(thefuck_version, python_version):
|
def version(thefuck_version, python_version):
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
u'The Fuck {} using Python {}'.format(thefuck_version,
|
u'The Fuck {} using Python {}\n'.format(thefuck_version,
|
||||||
python_version))
|
python_version))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from thefuck.utils import get_all_executables, memoize, which
|
from thefuck.utils import get_all_executables, memoize
|
||||||
|
|
||||||
|
|
||||||
@memoize
|
@memoize
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ patterns = ['permission denied',
|
|||||||
'edspermissionerror',
|
'edspermissionerror',
|
||||||
'you don\'t have write permissions',
|
'you don\'t have write permissions',
|
||||||
'use `sudo`',
|
'use `sudo`',
|
||||||
'SudoRequiredError']
|
'SudoRequiredError',
|
||||||
|
'error: insufficient privileges']
|
||||||
|
|
||||||
|
|
||||||
def match(command):
|
def match(command):
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
from thefuck.utils import for_app, eager, replace_command
|
from thefuck.utils import for_app, eager, replace_command, replace_argument
|
||||||
|
|
||||||
regex = re.compile(r'error Command "(.*)" not found.')
|
regex = re.compile(r'error Command "(.*)" not found.')
|
||||||
|
|
||||||
@@ -10,6 +10,9 @@ def match(command):
|
|||||||
return regex.findall(command.stderr)
|
return regex.findall(command.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
npm_commands = {'require': 'add'}
|
||||||
|
|
||||||
|
|
||||||
@eager
|
@eager
|
||||||
def _get_all_tasks():
|
def _get_all_tasks():
|
||||||
proc = Popen(['yarn', '--help'], stdout=PIPE)
|
proc = Popen(['yarn', '--help'], stdout=PIPE)
|
||||||
@@ -27,5 +30,9 @@ def _get_all_tasks():
|
|||||||
|
|
||||||
def get_new_command(command):
|
def get_new_command(command):
|
||||||
misspelled_task = regex.findall(command.stderr)[0]
|
misspelled_task = regex.findall(command.stderr)[0]
|
||||||
|
if misspelled_task in npm_commands:
|
||||||
|
yarn_command = npm_commands[misspelled_task]
|
||||||
|
return replace_argument(command.script, misspelled_task, yarn_command)
|
||||||
|
else:
|
||||||
tasks = _get_all_tasks()
|
tasks = _get_all_tasks()
|
||||||
return replace_command(command, misspelled_task, tasks)
|
return replace_command(command, misspelled_task, tasks)
|
||||||
|
|||||||
@@ -11,12 +11,14 @@ class Bash(Generic):
|
|||||||
return '''
|
return '''
|
||||||
function {name} () {{
|
function {name} () {{
|
||||||
TF_PREVIOUS=$(fc -ln -1);
|
TF_PREVIOUS=$(fc -ln -1);
|
||||||
|
TF_PYTHONIOENCODING=$PYTHONIOENCODING;
|
||||||
|
export TF_ALIAS={name};
|
||||||
|
export TF_SHELL_ALIASES=$(alias);
|
||||||
|
export PYTHONIOENCODING=utf-8;
|
||||||
TF_CMD=$(
|
TF_CMD=$(
|
||||||
TF_ALIAS={name}
|
|
||||||
TF_SHELL_ALIASES=$(alias)
|
|
||||||
PYTHONIOENCODING=utf-8
|
|
||||||
thefuck $TF_PREVIOUS {argument_placeholder} $@
|
thefuck $TF_PREVIOUS {argument_placeholder} $@
|
||||||
) && eval $TF_CMD;
|
) && eval $TF_CMD;
|
||||||
|
export PYTHONIOENCODING=$TF_PYTHONIOENCODING;
|
||||||
{alter_history}
|
{alter_history}
|
||||||
}}
|
}}
|
||||||
'''.format(
|
'''.format(
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import sys
|
|||||||
from .conf import settings
|
from .conf import settings
|
||||||
from .exceptions import NoRuleMatched
|
from .exceptions import NoRuleMatched
|
||||||
from .system import get_key
|
from .system import get_key
|
||||||
|
from .utils import get_alias
|
||||||
from . import logs, const
|
from . import logs, const
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +70,8 @@ def select_command(corrected_commands):
|
|||||||
try:
|
try:
|
||||||
selector = CommandSelector(corrected_commands)
|
selector = CommandSelector(corrected_commands)
|
||||||
except NoRuleMatched:
|
except NoRuleMatched:
|
||||||
logs.failed('No fucks given')
|
logs.failed('No fucks given' if get_alias() == 'fuck'
|
||||||
|
else 'Nothing found')
|
||||||
return
|
return
|
||||||
|
|
||||||
if not settings.require_confirmation:
|
if not settings.require_confirmation:
|
||||||
|
|||||||
Reference in New Issue
Block a user