1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-05 18:31:10 +01:00

Merge branch 'java' of https://github.com/diezcami/thefuck into diezcami-java

Conflicts:
	README.md
This commit is contained in:
nvbn 2015-05-28 18:03:24 +03:00
commit 73bc6c0184
3 changed files with 32 additions and 1 deletions

View File

@ -155,7 +155,8 @@ using the matched rule and runs it. Rules enabled by default are as follows:
* `django_south_ghost` – adds `--delete-ghost-migrations` to failed because ghosts django south migration;
* `django_south_merge` – adds `--merge` to inconsistent django south migration;
* `fix_alt_space` – replaces Alt+Space with Space character;
* `javac` – appends missing `.java` when compiling Java files
* `javac` – appends missing `.java` when compiling Java files;
* `java` – removes `.java` extension when running Java programs;
* `git_add` – fix *"Did you forget to 'git add'?"*;
* `git_checkout` – creates the branch before checking-out;
* `git_no_command` – fixes wrong git commands like `git brnch`;

17
tests/rules/test_java.py Normal file
View File

@ -0,0 +1,17 @@
import pytest
from thefuck.rules.java import match, get_new_command
from tests.utils import Command
@pytest.mark.parametrize('command', [
Command(script='java foo.java'),
Command(script='java bar.java')])
def test_match(command):
assert match(command, None)
@pytest.mark.parametrize('command, new_command', [
(Command('java foo.java'), 'java foo'),
(Command('java bar.java'), 'java bar')])
def test_get_new_command(command, new_command):
assert get_new_command(command, None) == new_command

13
thefuck/rules/java.py Normal file
View File

@ -0,0 +1,13 @@
# Fixes common java command mistake
#
# Example:
# > java foo.java
# Error: Could not find or load main class foo.java
#
def match(command, settings):
return (command.script.startswith ('java ')
and command.script.endswith ('.java'))
def get_new_command(command, settings):
return command.script[:-5]