mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 10:11:14 +00:00
Added javac rule
This commit is contained in:
parent
718cadb85a
commit
a9e3b22fa4
@ -155,6 +155,7 @@ 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_ghost` – adds `--delete-ghost-migrations` to failed because ghosts django south migration;
|
||||||
* `django_south_merge` – adds `--merge` to inconsistent django south migration;
|
* `django_south_merge` – adds `--merge` to inconsistent django south migration;
|
||||||
* `fix_alt_space` – replaces Alt+Space with Space character;
|
* `fix_alt_space` – replaces Alt+Space with Space character;
|
||||||
|
* `javac` – appends missing `.java` when compiling Java files
|
||||||
* `git_add` – fix *"Did you forget to 'git add'?"*;
|
* `git_add` – fix *"Did you forget to 'git add'?"*;
|
||||||
* `git_checkout` – creates the branch before checking-out;
|
* `git_checkout` – creates the branch before checking-out;
|
||||||
* `git_no_command` – fixes wrong git commands like `git brnch`;
|
* `git_no_command` – fixes wrong git commands like `git brnch`;
|
||||||
|
17
tests/rules/test_javac.py
Normal file
17
tests/rules/test_javac.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import pytest
|
||||||
|
from thefuck.rules.javac import match, get_new_command
|
||||||
|
from tests.utils import Command
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command', [
|
||||||
|
Command(script='javac foo'),
|
||||||
|
Command(script='javac bar')])
|
||||||
|
def test_match(command):
|
||||||
|
assert match(command, None)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command, new_command', [
|
||||||
|
(Command('javac foo'), 'javac foo.java'),
|
||||||
|
(Command('javac bar'), 'javac bar.java')])
|
||||||
|
def test_get_new_command(command, new_command):
|
||||||
|
assert get_new_command(command, None) == new_command
|
15
thefuck/rules/javac.py
Normal file
15
thefuck/rules/javac.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Appends .java when compiling java files
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# > javac foo
|
||||||
|
# error: Class names, 'foo', are only accepted if annotation
|
||||||
|
# processing is explicitly requested
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
def match(command, settings):
|
||||||
|
return (command.script.startswith ('javac ')
|
||||||
|
and not command.script.endswith('.java'))
|
||||||
|
|
||||||
|
def get_new_command(command, settings):
|
||||||
|
return command.script + '.java'
|
Loading…
x
Reference in New Issue
Block a user