mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
#612: Little cleanup
This commit is contained in:
parent
4b53b1d3e3
commit
c7d7a6d1d7
@ -51,6 +51,7 @@ def test_match(command):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command, new_command', [
|
@pytest.mark.parametrize('command, new_command', [
|
||||||
(Command('yarn help clean', stdout=stdout_clean), open_command('https://yarnpkg.com/en/docs/cli/clean'))])
|
(Command('yarn help clean', stdout=stdout_clean),
|
||||||
|
open_command('https://yarnpkg.com/en/docs/cli/clean'))])
|
||||||
def test_get_new_command(command, new_command):
|
def test_get_new_command(command, new_command):
|
||||||
assert get_new_command(command) == new_command
|
assert get_new_command(command) == new_command
|
||||||
|
@ -5,10 +5,13 @@ from thefuck.system import open_command
|
|||||||
|
|
||||||
@for_app('yarn', at_least=2)
|
@for_app('yarn', at_least=2)
|
||||||
def match(command):
|
def match(command):
|
||||||
return command.script_parts[1] == 'help' and ('for documentation about this command.' in command.stdout)
|
return (command.script_parts[1] == 'help'
|
||||||
|
and 'for documentation about this command.' in command.stdout)
|
||||||
|
|
||||||
|
|
||||||
def get_new_command(command):
|
def get_new_command(command):
|
||||||
url = re.findall(r'Visit ([^ ]*) for documentation about this command.', command.stdout)[0]
|
url = re.findall(
|
||||||
|
r'Visit ([^ ]*) for documentation about this command.',
|
||||||
|
command.stdout)[0]
|
||||||
|
|
||||||
return open_command(url)
|
return open_command(url)
|
||||||
|
@ -38,7 +38,7 @@ def get_key():
|
|||||||
|
|
||||||
|
|
||||||
def open_command(arg):
|
def open_command(arg):
|
||||||
if (find_executable('xdg-open')):
|
if find_executable('xdg-open'):
|
||||||
return 'xdg-open ' + arg
|
return 'xdg-open ' + arg
|
||||||
return 'open ' + arg
|
return 'open ' + arg
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@ def get_key():
|
|||||||
if ch == b'P':
|
if ch == b'P':
|
||||||
return const.KEY_DOWN
|
return const.KEY_DOWN
|
||||||
|
|
||||||
encoding = sys.stdout.encoding or os.environ.get('PYTHONIOENCODING', 'utf-8')
|
encoding = (sys.stdout.encoding
|
||||||
|
or os.environ.get('PYTHONIOENCODING', 'utf-8'))
|
||||||
return ch.decode(encoding)
|
return ch.decode(encoding)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user