mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
#298 Add support of list results in sudo_support
This commit is contained in:
parent
e6af00ef97
commit
4bc1cc7849
@ -18,6 +18,7 @@ def test_wrap_settings(override, old, new):
|
|||||||
@pytest.mark.parametrize('return_value, command, called, result', [
|
@pytest.mark.parametrize('return_value, command, called, result', [
|
||||||
('ls -lah', 'sudo ls', 'ls', 'sudo ls -lah'),
|
('ls -lah', 'sudo ls', 'ls', 'sudo ls -lah'),
|
||||||
('ls -lah', 'ls', 'ls', 'ls -lah'),
|
('ls -lah', 'ls', 'ls', 'ls -lah'),
|
||||||
|
(['ls -lah'], 'sudo ls', 'ls', ['sudo ls -lah']),
|
||||||
(True, 'sudo ls', 'ls', True),
|
(True, 'sudo ls', 'ls', True),
|
||||||
(True, 'ls', 'ls', True),
|
(True, 'ls', 'ls', True),
|
||||||
(False, 'sudo ls', 'ls', False),
|
(False, 'sudo ls', 'ls', False),
|
||||||
|
@ -69,6 +69,8 @@ def sudo_support(fn):
|
|||||||
|
|
||||||
if result and isinstance(result, six.string_types):
|
if result and isinstance(result, six.string_types):
|
||||||
return u'sudo {}'.format(result)
|
return u'sudo {}'.format(result)
|
||||||
|
elif isinstance(result, list):
|
||||||
|
return [u'sudo {}'.format(x) for x in result]
|
||||||
else:
|
else:
|
||||||
return result
|
return result
|
||||||
return wrapper
|
return wrapper
|
||||||
@ -161,6 +163,14 @@ def replace_argument(script, from_, to):
|
|||||||
u' {} '.format(from_), u' {} '.format(to), 1)
|
u' {} '.format(from_), u' {} '.format(to), 1)
|
||||||
|
|
||||||
|
|
||||||
|
def eager(fn):
|
||||||
|
@wraps(fn)
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
return list(fn(*args, **kwargs))
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
@eager
|
||||||
def get_all_matched_commands(stderr, separator='Did you mean'):
|
def get_all_matched_commands(stderr, separator='Did you mean'):
|
||||||
should_yield = False
|
should_yield = False
|
||||||
for line in stderr.split('\n'):
|
for line in stderr.split('\n'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user