1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-05 18:31:10 +01:00

basic support for the hdfs dfs <command> when the command misses the dash

This commit is contained in:
Michael Lee 2015-08-13 13:09:19 +01:00
parent 0ad70a1edc
commit b494c4e273
3 changed files with 41 additions and 0 deletions

View File

@ -192,6 +192,7 @@ using the matched rule and runs it. Rules enabled by default are as follows:
* `tsuru_not_command` &ndash; fixes wrong tsuru commands like `tsuru shell`;
* `tmux` &ndash; fixes `tmux` commands;
* `whois` &ndash; fixes `whois` command.
* `hdfs dfs` &ndash; Add the missing dash to the command.
Enabled by default only on specific platforms:

View File

@ -0,0 +1,30 @@
import pytest
from thefuck.rules.hadoop_dfs_missing_dash import match, get_new_command
from tests.utils import Command
@pytest.mark.parametrize('command', [
Command(script='./bin/hdfs dfs ls', stderr='ls: Unknown command\nDid you mean -ls? This command begins with a dash.'),
Command(script='hdfs dfs ls',
stderr='ls: Unknown command\nDid you mean -ls? This command begins with a dash.'),
Command(script='hdfs dfs ls /foo/bar', stderr='ls: Unknown command\nDid you mean -ls? This command begins with a dash.')])
def test_match(command):
assert match(command, None)
@pytest.mark.parametrize('command', [
Command(script='./bin/hdfs dfs -ls', stderr=''),
Command(script='./bin/hdfs dfs -ls /foo/bar', stderr=''),
Command(script='hdfs dfs -ls -R /foo/bar', stderr=''),
Command()])
def test_not_match(command):
assert not match(command, None)
@pytest.mark.parametrize('command, new_command', [
(Command('hdfs dfs ls'), 'hdfs dfs -ls'),
(Command('hdfs dfs ls /foo/bar'), 'hdfs dfs -ls /foo/bar'),
(Command('./bin/hdfs dfs ls -R /foo/bar'), './bin/hdfs dfs -ls -R /foo/bar')])
def test_get_new_command(command, new_command):
assert get_new_command(command, None) == new_command

View File

@ -0,0 +1,10 @@
def match(command, settings):
return ('hdfs dfs' in command.script
and "this command begins with a dash." in command.stderr.lower())
def get_new_command(command, settings):
data = command.script.split()
data[2] = '-' + data[2]
return ' '.join(data)