1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-01 16:28:37 +00:00

Version Command

This commit is contained in:
Roopesh V S 2020-08-03 17:02:22 +05:30
parent c196e2901c
commit 866e1839a7
2 changed files with 37 additions and 0 deletions

View 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
View 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'