1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-13 22:28:33 +00:00

#N/A: Check that brew/apt available in related rules

This commit is contained in:
nvbn 2016-02-06 16:37:11 +03:00
parent 778d5f3e6e
commit 28d078708b
8 changed files with 22 additions and 7 deletions

View File

@ -1,8 +1,10 @@
from thefuck.specific.apt import apt_available
from thefuck.utils import memoize
from thefuck.shells import shell
try:
import CommandNotFound
enabled_by_default = apt_available
except ImportError:
enabled_by_default = False

View File

@ -1,6 +1,9 @@
import re
from thefuck.specific.apt import apt_available
from thefuck.utils import for_app
enabled_by_default = apt_available
@for_app('apt-get')
def match(command):

View File

@ -1,7 +1,10 @@
import subprocess
from thefuck.specific.apt import apt_available
from thefuck.specific.sudo import sudo_support
from thefuck.utils import for_app, eager, replace_command
enabled_by_default = apt_available
@for_app('apt', 'apt-get', 'apt-cache')
@sudo_support

View File

@ -1,10 +1,9 @@
import os
import re
from thefuck.utils import get_closest, replace_argument, which
from thefuck.specific.brew import get_brew_path_prefix
from thefuck.utils import get_closest, replace_argument
from thefuck.specific.brew import get_brew_path_prefix, brew_available
enabled_by_default = bool(which('brew'))
enabled_by_default = brew_available
def _get_formulas():

View File

@ -1,12 +1,14 @@
import os
import re
from thefuck.utils import get_closest, replace_command
from thefuck.specific.brew import get_brew_path_prefix
from thefuck.specific.brew import get_brew_path_prefix, brew_available
BREW_CMD_PATH = '/Library/Homebrew/cmd'
TAP_PATH = '/Library/Taps'
TAP_CMD_PATH = '/%s/%s/cmd'
enabled_by_default = brew_available
def _get_brew_commands(brew_path_prefix):
"""To get brew default commands on local environment"""
@ -53,7 +55,7 @@ def _brew_commands():
if brew_path_prefix:
try:
return _get_brew_commands(brew_path_prefix) \
+ _get_brew_tap_specific_commands(brew_path_prefix)
+ _get_brew_tap_specific_commands(brew_path_prefix)
except OSError:
pass

View File

@ -4,6 +4,9 @@
# > brew upgrade
# Warning: brew upgrade with no arguments will change behaviour soon!
# It currently upgrades all formula but this will soon change to require '--all'.
from thefuck.specific.brew import brew_available
enabled_by_default = brew_available
def match(command):

3
thefuck/specific/apt.py Normal file
View File

@ -0,0 +1,3 @@
from thefuck.utils import which
apt_available = bool(which('apt-get'))

View File

@ -2,7 +2,7 @@ import subprocess
from ..utils import memoize, which
enabled_by_default = bool(which('brew'))
brew_available = bool(which('brew'))
@memoize