From d8ddf5a2be9d52ec4bc8c11e79fcc7b3c390b669 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Sun, 27 Mar 2022 22:06:40 +0200 Subject: [PATCH] #1279: Add pikaur AUR manager to Arch Linux's commands * Add pikaur AUR manager to Arch Linux's commands * Update README.md * Update test_pacman_not_found.py * Update pacman_not_found.py * Update README.md Co-authored-by: Pablo Aguiar --- README.md | 4 ++-- tests/rules/test_pacman_not_found.py | 4 ++++ thefuck/rules/pacman_not_found.py | 2 +- thefuck/specific/archlinux.py | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 182acce8..0a106059 100644 --- a/README.md +++ b/README.md @@ -360,9 +360,9 @@ The following rules are enabled by default on specific platforms only: * `brew_update_formula` – turns `brew update ` into `brew upgrade `; * `dnf_no_such_command` – fixes mistyped DNF commands; * `nixos_cmd_not_found` – installs apps on NixOS; -* `pacman` – installs app with `pacman` if it is not installed (uses `yay` or `yaourt` if available); +* `pacman` – installs app with `pacman` if it is not installed (uses `yay`, `pikaur` or `yaourt` if available); * `pacman_invalid_option` – replaces lowercase `pacman` options with uppercase. -* `pacman_not_found` – fixes package name with `pacman`, `yay` or `yaourt`. +* `pacman_not_found` – fixes package name with `pacman`, `yay`, `pikaur` or `yaourt`. * `yum_invalid_operation` – fixes invalid `yum` calls, like `yum isntall vim`; The following commands are bundled with *The Fuck*, but are not enabled by diff --git a/tests/rules/test_pacman_not_found.py b/tests/rules/test_pacman_not_found.py index a1b65327..22c0609b 100644 --- a/tests/rules/test_pacman_not_found.py +++ b/tests/rules/test_pacman_not_found.py @@ -12,6 +12,7 @@ extra/llvm35 3.5.2-13/usr/bin/llc''' reason='Skip if pacman is not available') @pytest.mark.parametrize('command', [ Command('yay -S llc', 'error: target not found: llc'), + Command('pikaur -S llc', 'error: target not found: llc'), Command('yaourt -S llc', 'error: target not found: llc'), Command('pacman llc', 'error: target not found: llc'), Command('sudo pacman llc', 'error: target not found: llc')]) @@ -21,6 +22,7 @@ def test_match(command): @pytest.mark.parametrize('command', [ Command('yay -S llc', 'error: target not found: llc'), + Command('pikaur -S llc', 'error: target not found: llc'), Command('yaourt -S llc', 'error: target not found: llc'), Command('pacman llc', 'error: target not found: llc'), Command('sudo pacman llc', 'error: target not found: llc')]) @@ -34,6 +36,7 @@ def test_match_mocked(subp_mock, command): reason='Skip if pacman is not available') @pytest.mark.parametrize('command, fixed', [ (Command('yay -S llc', 'error: target not found: llc'), ['yay -S extra/llvm', 'yay -S extra/llvm35']), + (Command('pikaur -S llc', 'error: target not found: llc'), ['pikaur -S extra/llvm', 'pikaur -S extra/llvm35']), (Command('yaourt -S llc', 'error: target not found: llc'), ['yaourt -S extra/llvm', 'yaourt -S extra/llvm35']), (Command('pacman -S llc', 'error: target not found: llc'), ['pacman -S extra/llvm', 'pacman -S extra/llvm35']), (Command('sudo pacman -S llc', 'error: target not found: llc'), ['sudo pacman -S extra/llvm', 'sudo pacman -S extra/llvm35'])]) @@ -43,6 +46,7 @@ def test_get_new_command(command, fixed): @pytest.mark.parametrize('command, fixed', [ (Command('yay -S llc', 'error: target not found: llc'), ['yay -S extra/llvm', 'yay -S extra/llvm35']), + (Command('pikaur -S llc', 'error: target not found: llc'), ['pikaur -S extra/llvm', 'pikaur -S extra/llvm35']), (Command('yaourt -S llc', 'error: target not found: llc'), ['yaourt -S extra/llvm', 'yaourt -S extra/llvm35']), (Command('pacman -S llc', 'error: target not found: llc'), ['pacman -S extra/llvm', 'pacman -S extra/llvm35']), (Command('sudo pacman -S llc', 'error: target not found: llc'), ['sudo pacman -S extra/llvm', 'sudo pacman -S extra/llvm35'])]) diff --git a/thefuck/rules/pacman_not_found.py b/thefuck/rules/pacman_not_found.py index 4e55b0c0..c1ce2922 100644 --- a/thefuck/rules/pacman_not_found.py +++ b/thefuck/rules/pacman_not_found.py @@ -12,7 +12,7 @@ from thefuck.specific.archlinux import get_pkgfile, archlinux_env def match(command): return (command.script_parts - and (command.script_parts[0] in ('pacman', 'yay', 'yaourt') + and (command.script_parts[0] in ('pacman', 'yay', 'pikaur', 'yaourt') or command.script_parts[0:2] == ['sudo', 'pacman']) and 'error: target not found:' in command.output) diff --git a/thefuck/specific/archlinux.py b/thefuck/specific/archlinux.py index 2d9e7b93..a64bfda9 100644 --- a/thefuck/specific/archlinux.py +++ b/thefuck/specific/archlinux.py @@ -34,6 +34,8 @@ def get_pkgfile(command): def archlinux_env(): if utils.which('yay'): pacman = 'yay' + elif utils.which('pikaur'): + pacman = 'pikaur' elif utils.which('yaourt'): pacman = 'yaourt' elif utils.which('pacman'):