mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-14 06:38:32 +00:00
#N/A: Check that brew/apt available in related rules
This commit is contained in:
parent
778d5f3e6e
commit
28d078708b
@ -1,8 +1,10 @@
|
|||||||
|
from thefuck.specific.apt import apt_available
|
||||||
from thefuck.utils import memoize
|
from thefuck.utils import memoize
|
||||||
from thefuck.shells import shell
|
from thefuck.shells import shell
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import CommandNotFound
|
import CommandNotFound
|
||||||
|
enabled_by_default = apt_available
|
||||||
except ImportError:
|
except ImportError:
|
||||||
enabled_by_default = False
|
enabled_by_default = False
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import re
|
import re
|
||||||
|
from thefuck.specific.apt import apt_available
|
||||||
from thefuck.utils import for_app
|
from thefuck.utils import for_app
|
||||||
|
|
||||||
|
enabled_by_default = apt_available
|
||||||
|
|
||||||
|
|
||||||
@for_app('apt-get')
|
@for_app('apt-get')
|
||||||
def match(command):
|
def match(command):
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
from thefuck.specific.apt import apt_available
|
||||||
from thefuck.specific.sudo import sudo_support
|
from thefuck.specific.sudo import sudo_support
|
||||||
from thefuck.utils import for_app, eager, replace_command
|
from thefuck.utils import for_app, eager, replace_command
|
||||||
|
|
||||||
|
enabled_by_default = apt_available
|
||||||
|
|
||||||
|
|
||||||
@for_app('apt', 'apt-get', 'apt-cache')
|
@for_app('apt', 'apt-get', 'apt-cache')
|
||||||
@sudo_support
|
@sudo_support
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from thefuck.utils import get_closest, replace_argument, which
|
from thefuck.utils import get_closest, replace_argument
|
||||||
from thefuck.specific.brew import get_brew_path_prefix
|
from thefuck.specific.brew import get_brew_path_prefix, brew_available
|
||||||
|
|
||||||
|
enabled_by_default = brew_available
|
||||||
enabled_by_default = bool(which('brew'))
|
|
||||||
|
|
||||||
|
|
||||||
def _get_formulas():
|
def _get_formulas():
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from thefuck.utils import get_closest, replace_command
|
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'
|
BREW_CMD_PATH = '/Library/Homebrew/cmd'
|
||||||
TAP_PATH = '/Library/Taps'
|
TAP_PATH = '/Library/Taps'
|
||||||
TAP_CMD_PATH = '/%s/%s/cmd'
|
TAP_CMD_PATH = '/%s/%s/cmd'
|
||||||
|
|
||||||
|
enabled_by_default = brew_available
|
||||||
|
|
||||||
|
|
||||||
def _get_brew_commands(brew_path_prefix):
|
def _get_brew_commands(brew_path_prefix):
|
||||||
"""To get brew default commands on local environment"""
|
"""To get brew default commands on local environment"""
|
||||||
@ -53,7 +55,7 @@ def _brew_commands():
|
|||||||
if brew_path_prefix:
|
if brew_path_prefix:
|
||||||
try:
|
try:
|
||||||
return _get_brew_commands(brew_path_prefix) \
|
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:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
# > brew upgrade
|
# > brew upgrade
|
||||||
# Warning: brew upgrade with no arguments will change behaviour soon!
|
# Warning: brew upgrade with no arguments will change behaviour soon!
|
||||||
# It currently upgrades all formula but this will soon change to require '--all'.
|
# 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):
|
def match(command):
|
||||||
|
3
thefuck/specific/apt.py
Normal file
3
thefuck/specific/apt.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from thefuck.utils import which
|
||||||
|
|
||||||
|
apt_available = bool(which('apt-get'))
|
@ -2,7 +2,7 @@ import subprocess
|
|||||||
from ..utils import memoize, which
|
from ..utils import memoize, which
|
||||||
|
|
||||||
|
|
||||||
enabled_by_default = bool(which('brew'))
|
brew_available = bool(which('brew'))
|
||||||
|
|
||||||
|
|
||||||
@memoize
|
@memoize
|
||||||
|
Loading…
x
Reference in New Issue
Block a user