1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 02:41:10 +01:00

#612: Little cleanup

This commit is contained in:
Vladimir Iakovlev 2017-03-13 13:30:07 +01:00
parent 4b53b1d3e3
commit c7d7a6d1d7
4 changed files with 10 additions and 5 deletions

View File

@ -51,6 +51,7 @@ def test_match(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):
assert get_new_command(command) == new_command

View File

@ -5,10 +5,13 @@ from thefuck.system import open_command
@for_app('yarn', at_least=2)
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):
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)

View File

@ -38,7 +38,7 @@ def get_key():
def open_command(arg):
if (find_executable('xdg-open')):
if find_executable('xdg-open'):
return 'xdg-open ' + arg
return 'open ' + arg

View File

@ -23,7 +23,8 @@ def get_key():
if ch == b'P':
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)