mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-19 04:21:14 +00:00
Merge pull request #239 from diezcami/quotation-marks
Added quotation_marks rule
This commit is contained in:
commit
581c97ec4b
@ -179,6 +179,7 @@ using the matched rule and runs it. Rules enabled by default are as follows:
|
|||||||
* `open` – prepends `http` to address passed to `open`;
|
* `open` – prepends `http` to address passed to `open`;
|
||||||
* `pip_unknown_command` – fixes wrong pip commands, for example `pip instatl/pip install`;
|
* `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;
|
* `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;
|
* `rm_dir` – adds `-rf` when you trying to remove directory;
|
||||||
* `sl_ls` – changes `sl` to `ls`;
|
* `sl_ls` – changes `sl` to `ls`;
|
||||||
* `ssh_known_hosts` – removes host from `known_hosts` on warning;
|
* `ssh_known_hosts` – removes host from `known_hosts` on warning;
|
||||||
|
19
tests/rules/test_quotation_marks.py
Normal file
19
tests/rules/test_quotation_marks.py
Normal 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
|
14
thefuck/rules/quotation_marks.py
Normal file
14
thefuck/rules/quotation_marks.py
Normal 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 ('\'', '\"')
|
Loading…
x
Reference in New Issue
Block a user