mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-14 06:38:32 +00:00
Merge bab3fc0f0e1a6694349ee38b699fcba821918b99 into c7e7e1d884d3bb241ea6448f72a989434c2a35ec
This commit is contained in:
commit
eeb118b239
@ -341,6 +341,7 @@ following rules are enabled by default:
|
||||
* `unknown_command` – fixes hadoop hdfs-style "unknown command", for example adds missing '-' to the command on `hdfs dfs ls`;
|
||||
* `unsudo` – removes `sudo` from previous command if a process refuses to run on superuser privilege.
|
||||
* `vagrant_up` – starts up the vagrant instance;
|
||||
* `version` – fixes wrong verion commands like `git -v` or `fuck -ver`;
|
||||
* `whois` – fixes `whois` command;
|
||||
* `workon_doesnt_exists` – fixes `virtualenvwrapper` env name os suggests to create new.
|
||||
* `wrong_hyphen_before_subcommand` – removes an improperly placed hyphen (`apt-install` -> `apt install`, `git-log` -> `git log`, etc.)
|
||||
|
20
tests/rules/test_version.py
Normal file
20
tests/rules/test_version.py
Normal file
@ -0,0 +1,20 @@
|
||||
import pytest
|
||||
from thefuck.rules.version import match, get_new_command
|
||||
from thefuck.types import Command
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command('git -v', ''),
|
||||
Command('git -version', ''),
|
||||
Command('git -version', ''),
|
||||
Command('fuck -ver', '')])
|
||||
def test_match(command):
|
||||
assert match(command)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command, new_command', [
|
||||
(Command('git -v', ''), 'git --version'),
|
||||
(Command('git -version', ''), 'git --version'),
|
||||
(Command('fuck -ver', ''), 'fuck --version')])
|
||||
def test_get_new_command(command, new_command):
|
||||
assert get_new_command(command) == new_command
|
17
thefuck/rules/version.py
Normal file
17
thefuck/rules/version.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Fixes incorrect usage of version commands
|
||||
#
|
||||
# Example :
|
||||
# > git -v
|
||||
# Here the correct usage is
|
||||
# > git --version
|
||||
|
||||
|
||||
def match(command):
|
||||
return ('-v' in command.script)
|
||||
|
||||
|
||||
def get_new_command(command):
|
||||
if '--version' in command.script:
|
||||
return command.script_parts[0] + ' -v'
|
||||
else:
|
||||
return command.script_parts[0] + ' --version'
|
Loading…
x
Reference in New Issue
Block a user