1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 14:48:49 +00:00

added rule for drmemory commands missing --

This commit is contained in:
Eli Schiff 2019-10-07 00:42:40 -04:00
parent 3bbd0e9463
commit cbdd7c4cc8
3 changed files with 49 additions and 2 deletions

View File

@ -192,6 +192,7 @@ following rules are enabled by default:
* `docker_login` – executes a `docker login` and repeats the previous command;
* `docker_not_command` – fixes wrong docker commands like `docker tags`;
* `docker_image_being_used_by_container` ‐ removes the container that is using the image before removing the image;
* `drmemory_no_dashdash` – adds `--` to drmemory commands;
* `dry` – fixes repetitions like `git git push`;
* `fab_command_not_found` – fix misspelled fabric commands;
* `fix_alt_space` – replaces Alt+Space with Space character;
@ -352,8 +353,8 @@ Your rule should not change `Command`.
**Rules api changed in 3.0:** To access a rule's settings, import it with
`from thefuck.conf import settings`
`settings` is a special object assembled from `~/.config/thefuck/settings.py`,
`settings` is a special object assembled from `~/.config/thefuck/settings.py`,
and values from env ([see more below](#settings)).
A simple example rule for running a script with `sudo`:

View File

@ -0,0 +1,27 @@
import pytest
from thefuck.rules.drmemory_no_dashdash import match, get_new_command
from thefuck.types import Command
@pytest.mark.parametrize('command', [
Command('drmemory a.out', 'Usage: drmemory [options] --'),
Command('/etc/bin/drmemory test.exe', 'Usage: drmemory [options] --'),
])
def test_match(command):
assert match(command)
@pytest.mark.parametrize('command', [
Command('drmemory -- a.out', ''),
Command('/etc/bin/drmemory -- test.exe', ''),
])
def test_not_match(command):
assert not match(command)
@pytest.mark.parametrize('command, new_command', [
(Command('drmemory a.out', ''), 'drmemory -- a.out'),
(Command('/etc/bin/drmemory test.exe', ''), '/etc/bin/drmemory -- test.exe'),
])
def test_get_new_command(command, new_command):
assert get_new_command(command) == new_command

View File

@ -0,0 +1,19 @@
from thefuck.specific.sudo import sudo_support
@sudo_support
def match(command):
return (
"drmemory" in command.script
and len(command.script.split()) >= 2
and "Usage: drmemory [options] --" in command.output
)
@sudo_support
def get_new_command(command):
return(
command.script.split()[0]
+ " -- "
+ " ".join(command.script.split()[1:])
)