mirror of
https://github.com/nvbn/thefuck.git
synced 2025-10-30 06:34:09 +00:00
Rename DEFAULT to DEFAULT_RULES
This commit is contained in:
@@ -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`:
|
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`;
|
* `require_confirmation` – require confirmation before running new command, by default `False`;
|
||||||
* `wait_command` – max amount of time in seconds for getting previous command output;
|
* `wait_command` – max amount of time in seconds for getting previous command output;
|
||||||
* `no_colors` – disable colored output.
|
* `no_colors` – disable colored output.
|
||||||
|
|
||||||
Or via environment variables:
|
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_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_WAIT_COMMAND` – max amount of time in seconds for getting previous command output;
|
||||||
* `THEFUCK_NO_COLORS` – disable colored output, `true/false`.
|
* `THEFUCK_NO_COLORS` – disable colored output, `true/false`.
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ def test_rules_names_list():
|
|||||||
|
|
||||||
|
|
||||||
def test_default():
|
def test_default():
|
||||||
assert Rule('test', None, None, True) in conf.DEFAULT
|
assert Rule('test', None, None, True) in conf.DEFAULT_RULES
|
||||||
assert Rule('test', None, None, False) not in conf.DEFAULT
|
assert Rule('test', None, None, False) not in conf.DEFAULT_RULES
|
||||||
assert Rule('test', None, None, False) in (conf.DEFAULT + ['test'])
|
assert Rule('test', None, None, False) in (conf.DEFAULT_RULES + ['test'])
|
||||||
|
|
||||||
|
|
||||||
def test_settings_defaults():
|
def test_settings_defaults():
|
||||||
@@ -37,13 +37,13 @@ def test_settings_from_file():
|
|||||||
|
|
||||||
|
|
||||||
def test_settings_from_file_with_DEFAULT():
|
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,
|
wait_command=10,
|
||||||
require_confirmation=True,
|
require_confirmation=True,
|
||||||
no_colors=True)), \
|
no_colors=True)), \
|
||||||
patch('thefuck.conf.os.environ', new_callable=lambda: {}):
|
patch('thefuck.conf.os.environ', new_callable=lambda: {}):
|
||||||
settings = conf.get_settings(Mock())
|
settings = conf.get_settings(Mock())
|
||||||
assert settings.rules == conf.DEFAULT + ['test']
|
assert settings.rules == conf.DEFAULT_RULES + ['test']
|
||||||
|
|
||||||
|
|
||||||
def test_settings_from_env():
|
def test_settings_from_env():
|
||||||
@@ -63,9 +63,9 @@ def test_settings_from_env():
|
|||||||
|
|
||||||
def test_settings_from_env_with_DEFAULT():
|
def test_settings_from_env_with_DEFAULT():
|
||||||
with patch('thefuck.conf.load_source', return_value=Mock()), \
|
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())
|
settings = conf.get_settings(Mock())
|
||||||
assert settings.rules == conf.DEFAULT + ['bash', 'lisp']
|
assert settings.rules == conf.DEFAULT_RULES + ['bash', 'lisp']
|
||||||
|
|
||||||
|
|
||||||
def test_update_settings():
|
def test_update_settings():
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ def test_get_rules():
|
|||||||
glob.return_value = [PosixPath('bash.py'), PosixPath('lisp.py')]
|
glob.return_value = [PosixPath('bash.py'), PosixPath('lisp.py')]
|
||||||
assert list(main.get_rules(
|
assert list(main.get_rules(
|
||||||
Path('~'),
|
Path('~'),
|
||||||
Mock(rules=conf.DEFAULT))) \
|
Mock(rules=conf.DEFAULT_RULES))) \
|
||||||
== [main.Rule('bash', 'bash', 'bash', True),
|
== [main.Rule('bash', 'bash', 'bash', True),
|
||||||
main.Rule('lisp', 'lisp', 'lisp', True),
|
main.Rule('lisp', 'lisp', 'lisp', True),
|
||||||
main.Rule('bash', 'bash', 'bash', True),
|
main.Rule('bash', 'bash', 'bash', True),
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class _DefaultRulesNames(RulesNamesList):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
DEFAULT = _DefaultRulesNames([])
|
DEFAULT_RULES = _DefaultRulesNames([])
|
||||||
|
|
||||||
|
|
||||||
class Settings(object):
|
class Settings(object):
|
||||||
@@ -45,7 +45,7 @@ class Settings(object):
|
|||||||
return Settings(conf)
|
return Settings(conf)
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_SETTINGS = {'rules': DEFAULT,
|
DEFAULT_SETTINGS = {'rules': DEFAULT_RULES,
|
||||||
'wait_command': 3,
|
'wait_command': 3,
|
||||||
'require_confirmation': False,
|
'require_confirmation': False,
|
||||||
'no_colors': False}
|
'no_colors': False}
|
||||||
@@ -68,8 +68,8 @@ def _settings_from_file(user_dir):
|
|||||||
def _rules_from_env(val):
|
def _rules_from_env(val):
|
||||||
"""Transforms rules list from env-string to python."""
|
"""Transforms rules list from env-string to python."""
|
||||||
val = val.split(':')
|
val = val.split(':')
|
||||||
if 'DEFAULT' in val:
|
if 'DEFAULT_RULES' in val:
|
||||||
val = DEFAULT + [rule for rule in val if rule != 'DEFAULT']
|
val = DEFAULT_RULES + [rule for rule in val if rule != 'DEFAULT_RULES']
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user