1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-18 12:06:04 +00:00

Rename DEFAULT to DEFAULT_RULES

This commit is contained in:
nvbn 2015-04-22 22:37:11 +02:00
parent 20b6c4c160
commit 54c408a6b5
4 changed files with 14 additions and 14 deletions

View File

@ -196,14 +196,14 @@ def get_new_command(command, settings):
The Fuck has a few settings parameters, they can be changed in `~/.thefuck/settings.py`:
* `rules` – list of enabled rules, by default `thefuck.conf.DEFAULT`;
* `rules` – list of enabled rules, by default `thefuck.conf.DEFAULT_RULES`;
* `require_confirmation` – require confirmation before running new command, by default `False`;
* `wait_command` – max amount of time in seconds for getting previous command output;
* `no_colors` – disable colored output.
Or via environment variables:
* `THEFUCK_RULES` – list of enabled rules, like `DEFAULT:rm_root` or `sudo:no_command`;
* `THEFUCK_RULES` – list of enabled rules, like `DEFAULT_RULES:rm_root` or `sudo:no_command`;
* `THEFUCK_REQUIRE_CONFIRMATION` – require confirmation before running new command, `true/false`;
* `THEFUCK_WAIT_COMMAND` – max amount of time in seconds for getting previous command output;
* `THEFUCK_NO_COLORS` – disable colored output, `true/false`.

View File

@ -11,9 +11,9 @@ def test_rules_names_list():
def test_default():
assert Rule('test', None, None, True) in conf.DEFAULT
assert Rule('test', None, None, False) not in conf.DEFAULT
assert Rule('test', None, None, False) in (conf.DEFAULT + ['test'])
assert Rule('test', None, None, True) in conf.DEFAULT_RULES
assert Rule('test', None, None, False) not in conf.DEFAULT_RULES
assert Rule('test', None, None, False) in (conf.DEFAULT_RULES + ['test'])
def test_settings_defaults():
@ -37,13 +37,13 @@ def test_settings_from_file():
def test_settings_from_file_with_DEFAULT():
with patch('thefuck.conf.load_source', return_value=Mock(rules=conf.DEFAULT + ['test'],
with patch('thefuck.conf.load_source', return_value=Mock(rules=conf.DEFAULT_RULES + ['test'],
wait_command=10,
require_confirmation=True,
no_colors=True)), \
patch('thefuck.conf.os.environ', new_callable=lambda: {}):
settings = conf.get_settings(Mock())
assert settings.rules == conf.DEFAULT + ['test']
assert settings.rules == conf.DEFAULT_RULES + ['test']
def test_settings_from_env():
@ -63,9 +63,9 @@ def test_settings_from_env():
def test_settings_from_env_with_DEFAULT():
with patch('thefuck.conf.load_source', return_value=Mock()), \
patch('thefuck.conf.os.environ', new_callable=lambda: {'THEFUCK_RULES': 'DEFAULT:bash:lisp'}):
patch('thefuck.conf.os.environ', new_callable=lambda: {'THEFUCK_RULES': 'DEFAULT_RULES:bash:lisp'}):
settings = conf.get_settings(Mock())
assert settings.rules == conf.DEFAULT + ['bash', 'lisp']
assert settings.rules == conf.DEFAULT_RULES + ['bash', 'lisp']
def test_update_settings():

View File

@ -25,7 +25,7 @@ def test_get_rules():
glob.return_value = [PosixPath('bash.py'), PosixPath('lisp.py')]
assert list(main.get_rules(
Path('~'),
Mock(rules=conf.DEFAULT))) \
Mock(rules=conf.DEFAULT_RULES))) \
== [main.Rule('bash', 'bash', 'bash', True),
main.Rule('lisp', 'lisp', 'lisp', True),
main.Rule('bash', 'bash', 'bash', True),

View File

@ -28,7 +28,7 @@ class _DefaultRulesNames(RulesNamesList):
return False
DEFAULT = _DefaultRulesNames([])
DEFAULT_RULES = _DefaultRulesNames([])
class Settings(object):
@ -45,7 +45,7 @@ class Settings(object):
return Settings(conf)
DEFAULT_SETTINGS = {'rules': DEFAULT,
DEFAULT_SETTINGS = {'rules': DEFAULT_RULES,
'wait_command': 3,
'require_confirmation': False,
'no_colors': False}
@ -68,8 +68,8 @@ def _settings_from_file(user_dir):
def _rules_from_env(val):
"""Transforms rules list from env-string to python."""
val = val.split(':')
if 'DEFAULT' in val:
val = DEFAULT + [rule for rule in val if rule != 'DEFAULT']
if 'DEFAULT_RULES' in val:
val = DEFAULT_RULES + [rule for rule in val if rule != 'DEFAULT_RULES']
return val