Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added pacman invalid option rule (#960)
* Added pacman invalid option rule * Added test * flake8 fixes * Test changes * Test fix * Typo - again * Travis test fix * More Travis * Even more travis * I hope im right here * Update README.md Co-Authored-By: Pablo Aguiar <scorphus@gmail.com> * Update thefuck/rules/pacman_invalid_option.py Co-Authored-By: Pablo Aguiar <scorphus@gmail.com> Co-authored-by: Pablo Aguiar <scorphus@gmail.com>
- Loading branch information
1 parent
d3a0542
commit 3c542a5
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from thefuck.rules.pacman_invalid_option import get_new_command, match | ||
from thefuck.types import Command | ||
|
||
good_output = "community/shared_meataxe 1.0-3\n A set of programs for working with matrix representations over finite fields\n " | ||
|
||
bad_output = "error: invalid option '-s'" | ||
|
||
|
||
def test_match(): | ||
assert not match(Command('pacman -Ss meat', good_output)) | ||
assert not match(Command('sudo pacman -Ss meat', good_output)) | ||
assert match(Command('pacman -ss meat', bad_output)) | ||
assert match(Command('sudo pacman -ss meat', bad_output)) | ||
|
||
|
||
def test_get_new_command(): | ||
new_command = get_new_command(Command('pacman -ss meat', bad_output)) | ||
assert new_command == 'pacman -Ss meat' | ||
|
||
new_command = get_new_command(Command('sudo pacman -s meat', bad_output)) | ||
assert new_command == 'sudo pacman -S meat' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from thefuck.specific.archlinux import archlinux_env | ||
import re | ||
|
||
|
||
def match(command): | ||
return "error: invalid option '-s'" in command.output | ||
|
||
|
||
def get_new_command(command): | ||
opt = re.findall(r" -[dqrstuf]", command.script)[0] | ||
return re.sub(opt, opt.upper(), command.script) | ||
|
||
|
||
enabled_by_default = archlinux_env() |