Skip to content

Commit 9544f7a

Browse files
committed
Fixed templates
Added JSON template for creating CLI inputs easier to manage
1 parent e42638c commit 9544f7a

File tree

9 files changed

+71
-16
lines changed

9 files changed

+71
-16
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[flake8]
22
max-line-length = 80
3-
extend-ignore = E203,E501,E701,E266,F403,F405, B008
3+
extend-ignore = E203,E501,E701,E266,F403,F405,B008,F401
44
exclude =
55
.eggs,
66
.git,

goals.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ A project would look like this:
2424
\---server1
2525
+---.env
2626
+---Dockerfile
27-
\---MINECRAFT FILES
27+
\---MINECRAFT FILES

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ disallow_subclassing_any = true
172172
warn_return_any = true
173173
warn_unused_configs = true
174174
warn_redundant_casts = true
175-
warn_unused_ignores = true
175+
warn_unused_ignores = false
176176
warn_no_return = true
177177
warn_unreachable = true
178178

src/assets/templates/.env.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ SERVER_JAR={{ env.SERVER_JAR | default('server.jar') }}
33
JAVA_ARGS="{{ env.JAVA_ARGS | default('') }}"
44
MIN_HEAP_SIZE={{ env.MIN_HEAP_SIZE | default(512) }}
55
MAX_HEAP_SIZE={{ env.MAX_HEAP_SIZE | default(2048) }}
6-
TYPE={{ env.TYPE | default('paper') }}
6+
TYPE={{ env.TYPE | default('server') }}
77

88
{% if env.HOST_PORTS is defined %}
9-
{% for name, port in env.HOST_PORTS %}
9+
{% for name, port in env.HOST_PORTS.items() %}
1010
{{ name }}={{ port }}
1111
{% endfor %}
1212
{% endif %}
1313

14-
CPU_LIMIT={{ env.CPU_LIMIT | default('1.0') }}
14+
CPUS_LIMIT={{ env.CPU_LIMIT | default('1.0') }}
1515
MEMORY_LIMIT={{ env.MEMORY_LIMIT | default('2g') }}
1616
CPU_RESERVATION={{ env.CPU_RESERVATION | default('0.5') }}
1717
MEMORY_RESERVATION={{ env.MEMORY_RESERVATION | default('1g') }}

src/assets/templates/docker-compose.yml.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
services:
2-
{% for name, svc in services.items() %}
3-
{{ name }}:
2+
{% for svc in services %}
3+
{{ svc.name }}:
44
build:
55
context: {{ svc.build.context }}
66
dockerfile: Dockerfile
77
env_file:
88
- {{ svc.env_file }}
9-
container_name: {{name}}
9+
container_name: {{ svc.name }}
1010
environment:
1111
- CONTAINER_NAME=${CONTAINER_NAME}
1212
- SERVER_JAR=${SERVER_JAR}

src/assets/templates/template.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"compose": {
3+
"services": [
4+
{
5+
"name": "server",
6+
"build": {
7+
"context": "./servers/server/"
8+
},
9+
"env_file": ".env.server",
10+
"volume": "./servers/server:/server",
11+
"ports": [
12+
"${HOST_PORT}:25565"
13+
],
14+
"expose": [
15+
25565
16+
],
17+
"networks": [
18+
"mc-network"
19+
],
20+
"resources": {
21+
"limits": {
22+
"cpus": 1,
23+
"memory": 1
24+
},
25+
"reservations": {
26+
"cpus": 1,
27+
"memory": 1
28+
}
29+
}
30+
}
31+
],
32+
"networks": [
33+
"mc-network"
34+
]
35+
},
36+
"envs": [
37+
{
38+
"CONTAINER_NAME": "server",
39+
"SERVER_JAR": "",
40+
"JAVA_ARGS": "",
41+
"MIN_HEAP_SIZE": "",
42+
"MAX_HEAP_SIZE": "",
43+
"TYPE": "",
44+
"HOST_PORTS": {
45+
"HOST_PORT": 25565
46+
},
47+
"CPU_LIMIT": 1,
48+
"MEMORY_LIMIT": 1,
49+
"CPU_RESERVATION": 1,
50+
"MEMORY_RESERVATION": 1
51+
}
52+
]
53+
}

src/cli/builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import inspect
44

5-
from InquirerPy import inquirer
6-
from InquirerPy.validator import EmptyInputValidator
5+
from InquirerPy import inquirer # type: ignore
6+
from InquirerPy.validator import EmptyInputValidator # type: ignore
77
from click import Command, Option
88

9+
from ..utils.cli import clear # type: ignore
910
from .custom_group import CustomGroup
10-
from ..utils.cli import clear
1111

1212

1313
class Builder(CustomGroup):

src/cli/manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import inspect
44

5-
from InquirerPy import inquirer
6-
from InquirerPy.validator import EmptyInputValidator
5+
from InquirerPy import inquirer # type: ignore
6+
from InquirerPy.validator import EmptyInputValidator # type: ignore
77
from click import Command, Option
88

9+
from ..utils.cli import clear # type: ignore
910
from .custom_group import CustomGroup
10-
from ..utils.cli import clear
1111

1212

1313
class Manager(CustomGroup):

src/utils/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from os import system, name
1+
from __future__ import annotations
2+
3+
from os import name, system
24
from time import sleep
35

46

0 commit comments

Comments
 (0)