mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 07:04:12 +00:00 
			
		
		
		
	#298 Add support of list results in sudo_support
				
					
				
			This commit is contained in:
		| @@ -18,6 +18,7 @@ def test_wrap_settings(override, old, new): | ||||
| @pytest.mark.parametrize('return_value, command, called, result', [ | ||||
|     ('ls -lah', 'sudo ls', 'ls', 'sudo ls -lah'), | ||||
|     ('ls -lah', 'ls', 'ls', 'ls -lah'), | ||||
|     (['ls -lah'], 'sudo ls', 'ls', ['sudo ls -lah']), | ||||
|     (True, 'sudo ls', 'ls', True), | ||||
|     (True, 'ls', 'ls', True), | ||||
|     (False, 'sudo ls', 'ls', False), | ||||
|   | ||||
| @@ -69,6 +69,8 @@ def sudo_support(fn): | ||||
|  | ||||
|         if result and isinstance(result, six.string_types): | ||||
|             return u'sudo {}'.format(result) | ||||
|         elif isinstance(result, list): | ||||
|             return [u'sudo {}'.format(x) for x in result] | ||||
|         else: | ||||
|             return result | ||||
|     return wrapper | ||||
| @@ -161,6 +163,14 @@ def replace_argument(script, from_, to): | ||||
|             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'): | ||||
|     should_yield = False | ||||
|     for line in stderr.split('\n'): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user