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

Added quotation marks rule

This commit is contained in:
Cami Diez 2015-06-02 13:18:13 +08:00
parent 13996261be
commit 79d94e2651
3 changed files with 34 additions and 0 deletions

View File

@ -178,6 +178,7 @@ using the matched rule and runs it. Rules enabled by default are as follows:
* `open` – prepends `http` to address passed to `open`;
* `pip_unknown_command` – fixes wrong pip commands, for example `pip instatl/pip install`;
* `python_command` – prepends `python` when you trying to run not executable/without `./` python script;
* `quotation_marks` – fixes uneven usage of `'` and `"` when containing args'
* `rm_dir` – adds `-rf` when you trying to remove directory;
* `sl_ls` – changes `sl` to `ls`;
* `ssh_known_hosts` – removes host from `known_hosts` on warning;

View File

@ -0,0 +1,19 @@
import pytest
from thefuck.rules.quotation_marks import match, get_new_command
from tests.utils import Command
@pytest.mark.parametrize('command', [
Command(script="git commit -m \'My Message\""),
Command(script="git commit -am \"Mismatched Quotation Marks\'"),
Command(script="echo \"hello\'")])
def test_match(command):
assert match(command, None)
@pytest.mark.parametrize('command, new_command', [
(Command("git commit -m \'My Message\""), "git commit -m \"My Message\""),
(Command("git commit -am \"Mismatched Quotation Marks\'"), "git commit -am \"Mismatched Quotation Marks\""),
(Command("echo \"hello\'"), "echo \"hello\"")])
def test_get_new_command(command, new_command):
assert get_new_command(command, None) == new_command

View File

@ -0,0 +1,14 @@
# Fixes careless " and ' usage
#
# Example:
# > git commit -m 'My Message"
#
#
#
def match(command, settings):
return ('\'' in command.script
and '\"' in command.script)
def get_new_command(command, settings):
return command.script.replace ('\'', '\"')