mcserver-cli 4.0.0.dev0__tar.gz → 4.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/CHANGELOG.md +29 -3
- mcserver_cli-4.3.0/CONTRIBUTING.md +16 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/NOTES.txt +52 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/PKG-INFO +6 -5
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/README.md +5 -4
- mcserver_cli-4.3.0/src/mcserver/__init__.py +1 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/cli.py +131 -157
- mcserver_cli-4.3.0/src/mcserver/commands/__init__.py +39 -0
- mcserver_cli-4.3.0/src/mcserver/commands/add_projects.py +239 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/import_setup.py +1 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/initialize_server.py +39 -15
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/list_projects.py +1 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/op_grant.py +1 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/op_list.py +1 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/op_revoke.py +1 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/print_help.py +1 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/remove_projects.py +1 -1
- mcserver_cli-4.3.0/src/mcserver/commands/search_projects.py +179 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/server_status.py +1 -1
- mcserver_cli-4.3.0/src/mcserver/commands/show_projects.py +105 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/start_server.py +26 -14
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/stop_server.py +2 -10
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/update_projects.py +1 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/whitelist_add.py +1 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/commands/whitelist_list.py +10 -9
- mcserver_cli-4.3.0/src/mcserver/commands/whitelist_remove.py +39 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/config.py +14 -3
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/fabricmc/meta.py +1 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/metadata.py +16 -6
- mcserver_cli-4.3.0/src/mcserver/modrinth/apis/__init__.py +9 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/apis/get_project_informations.py +49 -44
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/apis/get_project_versions.py +85 -40
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/apis/search_projects.py +64 -27
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/project_records.py +40 -28
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/shared.py +22 -20
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/slug_index.py +3 -7
- mcserver_cli-4.3.0/src/mcserver/modrinth/typings/__init__.py +50 -0
- mcserver_cli-4.0.0.dev0/src/mcserver/modrinth/typings/project_informations.py → mcserver_cli-4.3.0/src/mcserver/modrinth/typings/project_information.py +5 -3
- mcserver_cli-4.3.0/src/mcserver/modrinth/typings/project_version.py +90 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/mysterious.py +1 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/networking.py +3 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/paths.py +2 -1
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/resolver.py +47 -30
- mcserver_cli-4.3.0/src/mcserver/server_files/paths.py +3 -0
- mcserver_cli-4.3.0/src/mcserver/server_files/whitelist.py +138 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/shared.py +29 -7
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/zip_app.py +3 -1
- mcserver_cli-4.0.0.dev0/CONTRIBUTING.md +0 -9
- mcserver_cli-4.0.0.dev0/a.py +0 -72
- mcserver_cli-4.0.0.dev0/src/mcserver/__init__.py +0 -1
- mcserver_cli-4.0.0.dev0/src/mcserver/commands/__init__.py +0 -39
- mcserver_cli-4.0.0.dev0/src/mcserver/commands/add_projects.py +0 -148
- mcserver_cli-4.0.0.dev0/src/mcserver/commands/search_projects.py +0 -109
- mcserver_cli-4.0.0.dev0/src/mcserver/commands/show_projects.py +0 -29
- mcserver_cli-4.0.0.dev0/src/mcserver/commands/whitelist_remove.py +0 -33
- mcserver_cli-4.0.0.dev0/src/mcserver/modrinth/api.py +0 -768
- mcserver_cli-4.0.0.dev0/src/mcserver/modrinth/apis/__init__.py +0 -9
- mcserver_cli-4.0.0.dev0/src/mcserver/modrinth/project_records/metadata.py +0 -0
- mcserver_cli-4.0.0.dev0/src/mcserver/modrinth/project_records/relationships.py +0 -205
- mcserver_cli-4.0.0.dev0/src/mcserver/modrinth/project_records/shared.py +0 -8
- mcserver_cli-4.0.0.dev0/src/mcserver/modrinth/typings/__init__.py +0 -38
- mcserver_cli-4.0.0.dev0/src/mcserver/server_files/whitelist.py +0 -184
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/.gitignore +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/LICENSE +0 -0
- {mcserver_cli-4.0.0.dev0/src/mcserver → mcserver_cli-4.3.0/legacy}/mcserver_v2.0.0.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/pyproject.toml +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/__main__.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/__main__.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/app.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/caching.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/constants.py +0 -0
- {mcserver_cli-4.0.0.dev0/src/mcserver/legacyfabric → mcserver_cli-4.3.0/src/mcserver/legacy_fabric}/meta.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/minecraft/api.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/minecraft/player_identity.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/constants.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/modpack.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/paths.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/projects.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/typings/search_projects.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/modrinth/typings/shared.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/mojang/eula.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/mojang/manifest.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/papermc/api.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/purpurmc/api.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/quiltmc/meta.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/server_files/banned_ips.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/server_files/banned_players.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/server_files/ops.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/server_files/properties.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/server_files/usercaches.py +0 -0
- {mcserver_cli-4.0.0.dev0 → mcserver_cli-4.3.0}/src/mcserver/state.py +0 -0
|
@@ -5,16 +5,38 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [4.3.0] - 2026-11-02
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
+
- `whitelist remove` to remove players based on UUIDs or names
|
|
13
|
+
|
|
14
|
+
## [4.2.0] - 2026-11-02
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Reorder the `search` error message between 0 result and page is smaller than asked
|
|
19
|
+
|
|
20
|
+
## [4.1.0] - 2026-11-02
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- `search` now say "No environment"
|
|
25
|
+
- `search` correctly use the appropiate project type for the homepage
|
|
26
|
+
|
|
27
|
+
## [4.0.0] - 2026-10-31
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- Working `show` command
|
|
32
|
+
- Working `search` command
|
|
12
33
|
- New `--game-version` and `--loader` options to the `search` command
|
|
13
34
|
- New `--search-sort` and `--search-limit` options to the `init` command
|
|
14
|
-
-
|
|
15
35
|
|
|
16
36
|
### Changed
|
|
17
37
|
|
|
38
|
+
- Moved `slug_index.json` to global `.mcserver` cache
|
|
39
|
+
- More information that the `show` command output
|
|
18
40
|
- Better `search` info message
|
|
19
41
|
- slug_index.json is now a global cache
|
|
20
42
|
|
|
@@ -212,7 +234,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
212
234
|
- Better mod conflict error
|
|
213
235
|
- Faster mod resolving
|
|
214
236
|
|
|
215
|
-
[unreleased]: https://github.com/Othecat35/MCServer/compare/
|
|
237
|
+
[unreleased]: https://github.com/Othecat35/MCServer/compare/v4.3.0...HEAD
|
|
238
|
+
[4.3.0]: https://github.com/Othecat35/MCServer/compare/v4.2.0...v4.3.0
|
|
239
|
+
[4.2.0]: https://github.com/Othecat35/MCServer/compare/v4.1.0...v4.2.0
|
|
240
|
+
[4.1.0]: https://github.com/Othecat35/MCServer/compare/v4.0.0...v4.1.0
|
|
241
|
+
[4.0.0]: https://github.com/Othecat35/MCServer/compare/v3.0.0...v4.0.0
|
|
216
242
|
[3.0.0]: https://github.com/Othecat35/MCServer/compare/v2.0.0...v3.0.0
|
|
217
243
|
[2.0.0]: https://github.com/Othecat35/MCServer/compare/v1.13.16...v2.0.0
|
|
218
244
|
[1.13.16]: https://github.com/Othecat35/MCServer/compare/v1.13.15...v1.13.16
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
By submitting a pull request, you agree that your contribution is licensed under the MIT License.
|
|
4
|
+
|
|
5
|
+
# Development
|
|
6
|
+
|
|
7
|
+
- Python >= 3.12 (3.14 is recommended)
|
|
8
|
+
- Install with `pip install -e .`
|
|
9
|
+
- Use `ruff format` to reformat code
|
|
10
|
+
|
|
11
|
+
# Release
|
|
12
|
+
|
|
13
|
+
1. Bump version in `src/mcserver/__init__.py`
|
|
14
|
+
2. `python zip_app.py`
|
|
15
|
+
3. Tag: `git tag vX.Y.Z && git push --tags`
|
|
16
|
+
4. Create GitHub release, attach `dist/mcserver`
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
Pls don't feed my creation to AI ;>
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
A file where I dumped ideas for this project.
|
|
2
5
|
|
|
3
6
|
CLI Commands:
|
|
@@ -183,7 +186,9 @@ check_dependency_conflicts: no
|
|
|
183
186
|
resolve_dependencies: ok... what are dependencies of mod b?
|
|
184
187
|
(some dialogue later)
|
|
185
188
|
resolve_dependencies: ok, there's no more dependency. here you go "return the list of dependencies"
|
|
186
|
-
user: why are there 29 mods including dependencies 0_0
|
|
189
|
+
user: why are there 29 mods including dependencies 0_0 (basucally the resolver works)
|
|
190
|
+
|
|
191
|
+
on second thought, the caller is the one that handle conflict.
|
|
187
192
|
|
|
188
193
|
thx chatgpt but I can't prove it yet
|
|
189
194
|
|
|
@@ -199,7 +204,15 @@ thx chatgpt but I can't prove it yet
|
|
|
199
204
|
- Review codes, especially TypedDict, because why not
|
|
200
205
|
- Avoid making myself suffer in this project, potentially abandoning this cool project
|
|
201
206
|
- I hate CurseForge personally.
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
202
210
|
- And yet I still have no friend (to talk about my weird hobby of computer, including this)
|
|
211
|
+
|
|
212
|
+
- Oh hi Finjer! idk if you are reading this, cool. so uh... idk I added stuff I guess, or remove stuff.
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
203
216
|
- Add command such as 'whitelist add/remove/list', 'ban/unban/ban-list', and probably 'op/deop <player> <level>'
|
|
204
217
|
|
|
205
218
|
MCServer™ Naming Convention: (the Trademark is just a joke)
|
|
@@ -340,3 +353,41 @@ make a visualize command to visualize installed projects that output to graphviz
|
|
|
340
353
|
we should merge the metadata.json and relationships.json back into one file :o
|
|
341
354
|
|
|
342
355
|
look at myterious.py, idk why yiu thought it would be a good idea to make it more fun, and dynamic even.
|
|
356
|
+
mcserver export --client-setup seems nice
|
|
357
|
+
mcserver add thdilos-fox-origin -y is better
|
|
358
|
+
mcserver add jade --include-optional make sense, but for specifically requested mod that is client_only_server_optional, include them. otherwise, put them into "suggested" mods.
|
|
359
|
+
|
|
360
|
+
yo the get_project_informations() is broken because moderator_message can be null
|
|
361
|
+
as for every API interface/client, we can instead return parsed (for those who we already know the structure), and then another, extra (just a dict[str, Any]). call the new typeddict, *Data.
|
|
362
|
+
|
|
363
|
+
About lazy loading imports... what if I make it so that imports that are required regardless, just
|
|
364
|
+
import it on the module instead? because if you do import it, you must have a reason to do so. Like,
|
|
365
|
+
you don't import a module and not use it at all, right? so just move the imports outside the function.
|
|
366
|
+
init.py:
|
|
367
|
+
import argparse
|
|
368
|
+
|
|
369
|
+
def init(args: argparse.Namespace):
|
|
370
|
+
import logging
|
|
371
|
+
...
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
init.py:
|
|
375
|
+
import argparse
|
|
376
|
+
import logging
|
|
377
|
+
|
|
378
|
+
def init(args: argparse.Namespace):
|
|
379
|
+
...
|
|
380
|
+
|
|
381
|
+
so, if you import init, you of course want to run init() right? so lazy-laoding it is not just useless,
|
|
382
|
+
it also make the code a bit more unreadable.
|
|
383
|
+
When do we lazy-loading stuff? imports that aren't always needed. Like command invocation in cli.py
|
|
384
|
+
with match case, because you don't need any to print the help message (except the help command itself),
|
|
385
|
+
or if you did, like init, you don't neccesearily need to import the stop command right? and also other
|
|
386
|
+
case is in init.py and start.pt. it import the appropriate loader and not other.
|
|
387
|
+
|
|
388
|
+
hmmm yes, global .mcserver config, just like cache.
|
|
389
|
+
it can be the default config of all your new Minecraft server derived from
|
|
390
|
+
and yea
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
2026-11-01, let's start not using AI?
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: mcserver-cli
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.3.0
|
|
4
4
|
Summary: A CLI tool to manage Minecraft: Java Edition servers.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Othecat35/MCServer
|
|
6
6
|
Project-URL: Repository, https://github.com/Othecat35/MCServer.git
|
|
@@ -44,14 +44,15 @@ Supported platforms:
|
|
|
44
44
|
## Usage
|
|
45
45
|
- Initialize a server: `mcserver init [options]`
|
|
46
46
|
- List operator players: `mcserver op list`
|
|
47
|
+
- Show information about projects: `mcserver show <projects>`
|
|
47
48
|
- Start the server: `mcserver start`
|
|
48
|
-
- Stop the server: `mcserver stop`
|
|
49
|
+
- Stop the server: `mcserver stop [--force-stop]`
|
|
49
50
|
- List whitelisted players: `mcserver whitelist list`
|
|
50
51
|
|
|
51
52
|
### Example
|
|
52
|
-
- Create a 1.20.1
|
|
53
|
+
- Create and start a Fabric 1.20.1 server on current directory
|
|
53
54
|
```bash
|
|
54
|
-
mcserver init --
|
|
55
|
+
mcserver init --game-version=1.20.1 --loader=fabric
|
|
55
56
|
mcserver start
|
|
56
57
|
```
|
|
57
58
|
|
|
@@ -60,11 +61,11 @@ mcserver start
|
|
|
60
61
|
mcserver op list
|
|
61
62
|
mcserver whitelist list
|
|
62
63
|
```
|
|
64
|
+
|
|
63
65
|
- Stop (sigterm) a server on current directory
|
|
64
66
|
```bash
|
|
65
67
|
mcserver stop
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
|
|
69
70
|
## Note
|
|
70
71
|
This is a **Personal Project**, things may be unstable.
|
|
@@ -31,14 +31,15 @@ Supported platforms:
|
|
|
31
31
|
## Usage
|
|
32
32
|
- Initialize a server: `mcserver init [options]`
|
|
33
33
|
- List operator players: `mcserver op list`
|
|
34
|
+
- Show information about projects: `mcserver show <projects>`
|
|
34
35
|
- Start the server: `mcserver start`
|
|
35
|
-
- Stop the server: `mcserver stop`
|
|
36
|
+
- Stop the server: `mcserver stop [--force-stop]`
|
|
36
37
|
- List whitelisted players: `mcserver whitelist list`
|
|
37
38
|
|
|
38
39
|
### Example
|
|
39
|
-
- Create a 1.20.1
|
|
40
|
+
- Create and start a Fabric 1.20.1 server on current directory
|
|
40
41
|
```bash
|
|
41
|
-
mcserver init --
|
|
42
|
+
mcserver init --game-version=1.20.1 --loader=fabric
|
|
42
43
|
mcserver start
|
|
43
44
|
```
|
|
44
45
|
|
|
@@ -47,11 +48,11 @@ mcserver start
|
|
|
47
48
|
mcserver op list
|
|
48
49
|
mcserver whitelist list
|
|
49
50
|
```
|
|
51
|
+
|
|
50
52
|
- Stop (sigterm) a server on current directory
|
|
51
53
|
```bash
|
|
52
54
|
mcserver stop
|
|
53
55
|
```
|
|
54
56
|
|
|
55
|
-
|
|
56
57
|
## Note
|
|
57
58
|
This is a **Personal Project**, things may be unstable.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "4.3.0"
|
|
@@ -1,114 +1,119 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
from . import __version__
|
|
6
|
-
from .modrinth.shared import search_sort_index
|
|
7
|
-
from .shared import loader_list
|
|
8
|
-
|
|
9
|
-
def bound_int(min_integer: int, max_integer: int | None = None):
|
|
10
|
-
def parse(cli_string: str):
|
|
11
|
-
try:
|
|
12
|
-
integer = int(cli_string)
|
|
13
|
-
except TypeError:
|
|
14
|
-
raise argparse.ArgumentTypeError(f"{cli_string} is not an integer")
|
|
15
|
-
|
|
16
|
-
if integer <= min_integer:
|
|
17
|
-
raise argparse.ArgumentTypeError(
|
|
18
|
-
f"{integer} must be higher than or equal to {min_integer}"
|
|
19
|
-
)
|
|
20
|
-
if max_integer is not None and integer >= max_integer:
|
|
21
|
-
raise argparse.ArgumentTypeError(
|
|
22
|
-
f"{integer} must be between {min_integer} and {max_integer} (inclusive)"
|
|
23
|
-
)
|
|
24
|
-
return integer
|
|
25
|
-
|
|
26
|
-
return parse
|
|
27
|
-
|
|
28
|
-
def command_function(args: argparse.Namespace) -> int:
|
|
29
|
-
command_name: str = args.command_name
|
|
30
|
-
|
|
31
|
-
match command_name:
|
|
32
|
-
case "add":
|
|
33
|
-
from .commands import add_projects
|
|
34
|
-
|
|
35
|
-
return add_projects(args)
|
|
36
|
-
case "import":
|
|
37
|
-
from .commands import import_setup
|
|
38
|
-
|
|
39
|
-
return import_setup(args)
|
|
40
|
-
case "help":
|
|
41
|
-
from .commands import print_help
|
|
42
|
-
|
|
43
|
-
return print_help(args)
|
|
44
|
-
case "init":
|
|
45
|
-
from .commands import initialize_server
|
|
46
|
-
|
|
47
|
-
return initialize_server(args)
|
|
48
|
-
case "list":
|
|
49
|
-
from .commands import list_projects
|
|
50
|
-
|
|
51
|
-
return list_projects(args)
|
|
52
|
-
case "op_grant":
|
|
53
|
-
from .commands import op_grant
|
|
54
|
-
|
|
55
|
-
return op_grant(args)
|
|
56
|
-
case "op_list":
|
|
57
|
-
from .commands import op_list
|
|
58
|
-
|
|
59
|
-
return op_list(args)
|
|
60
|
-
case "op_revoke":
|
|
61
|
-
from .commands import op_revoke
|
|
62
|
-
|
|
63
|
-
return op_revoke(args)
|
|
64
|
-
case "remove":
|
|
65
|
-
from .commands import remove_projects
|
|
66
|
-
|
|
67
|
-
return remove_projects(args)
|
|
68
|
-
case "search":
|
|
69
|
-
from .commands import search_projects
|
|
70
|
-
|
|
71
|
-
return search_projects(args)
|
|
72
|
-
case "show":
|
|
73
|
-
from .commands import show_projects
|
|
74
|
-
|
|
75
|
-
return show_projects(args)
|
|
76
|
-
case "start":
|
|
77
|
-
from .commands import start_server
|
|
78
|
-
|
|
79
|
-
return start_server(args)
|
|
80
|
-
case "status":
|
|
81
|
-
from .commands import server_status
|
|
82
|
-
|
|
83
|
-
return server_status(args)
|
|
84
|
-
case "stop":
|
|
85
|
-
from .commands import stop_server
|
|
86
|
-
|
|
87
|
-
return stop_server(args)
|
|
88
|
-
case "update":
|
|
89
|
-
from .commands import update_projects
|
|
90
|
-
|
|
91
|
-
return update_projects(args)
|
|
92
|
-
case "whitelist_add":
|
|
93
|
-
from .commands import whitelist_add
|
|
94
|
-
|
|
95
|
-
return whitelist_add(args)
|
|
96
|
-
case "whitelist_list":
|
|
97
|
-
from .commands import whitelist_list
|
|
98
|
-
|
|
99
|
-
return whitelist_list(args)
|
|
100
|
-
case "whitelist_remove":
|
|
101
|
-
from .commands import whitelist_remove
|
|
102
|
-
|
|
103
|
-
return whitelist_remove(args)
|
|
104
|
-
case _:
|
|
105
|
-
import logging as log
|
|
106
|
-
|
|
107
|
-
log.error(f"Unknown command: {command_name}")
|
|
108
|
-
return 1
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
from types import FunctionType
|
|
109
4
|
|
|
110
|
-
|
|
5
|
+
from . import __version__
|
|
6
|
+
from .modrinth.shared import search_sort_index
|
|
7
|
+
from .shared import loader_list
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def bound_int(min_integer: int, max_integer: int | None = None) -> FunctionType:
|
|
11
|
+
def parse(cli_string: str) -> int:
|
|
12
|
+
try:
|
|
13
|
+
integer = int(cli_string)
|
|
14
|
+
except ValueError:
|
|
15
|
+
raise argparse.ArgumentTypeError(f"{cli_string} is not an integer")
|
|
16
|
+
|
|
17
|
+
if integer < min_integer:
|
|
18
|
+
raise argparse.ArgumentTypeError(
|
|
19
|
+
f"{integer} must be higher than or equal to {min_integer}"
|
|
20
|
+
)
|
|
21
|
+
if max_integer is not None and integer > max_integer:
|
|
22
|
+
raise argparse.ArgumentTypeError(
|
|
23
|
+
f"{integer} must be between {min_integer} and {max_integer} (inclusive)"
|
|
24
|
+
)
|
|
25
|
+
return integer
|
|
26
|
+
|
|
27
|
+
return parse
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def command_function(args: argparse.Namespace) -> int:
|
|
31
|
+
command_name: str = args.command_name
|
|
32
|
+
|
|
33
|
+
match command_name:
|
|
34
|
+
case "add":
|
|
35
|
+
from .commands import add_projects
|
|
36
|
+
|
|
37
|
+
return add_projects(args)
|
|
38
|
+
case "import":
|
|
39
|
+
from .commands import import_setup
|
|
40
|
+
|
|
41
|
+
return import_setup(args)
|
|
42
|
+
case "help":
|
|
43
|
+
from .commands import print_help
|
|
44
|
+
|
|
45
|
+
return print_help(args)
|
|
46
|
+
case "init":
|
|
47
|
+
from .commands import initialize_server
|
|
48
|
+
|
|
49
|
+
return initialize_server(args)
|
|
50
|
+
case "list":
|
|
51
|
+
from .commands import list_projects
|
|
52
|
+
|
|
53
|
+
return list_projects(args)
|
|
54
|
+
case "op_grant":
|
|
55
|
+
from .commands import op_grant
|
|
56
|
+
|
|
57
|
+
return op_grant(args)
|
|
58
|
+
case "op_list":
|
|
59
|
+
from .commands import op_list
|
|
60
|
+
|
|
61
|
+
return op_list(args)
|
|
62
|
+
case "op_revoke":
|
|
63
|
+
from .commands import op_revoke
|
|
64
|
+
|
|
65
|
+
return op_revoke(args)
|
|
66
|
+
case "remove":
|
|
67
|
+
from .commands import remove_projects
|
|
68
|
+
|
|
69
|
+
return remove_projects(args)
|
|
70
|
+
case "search":
|
|
71
|
+
from .commands import search_projects
|
|
72
|
+
|
|
73
|
+
return search_projects(args)
|
|
74
|
+
case "show":
|
|
75
|
+
from .commands import show_projects
|
|
76
|
+
|
|
77
|
+
return show_projects(args)
|
|
78
|
+
case "start":
|
|
79
|
+
from .commands import start_server
|
|
80
|
+
|
|
81
|
+
return start_server(args)
|
|
82
|
+
case "status":
|
|
83
|
+
from .commands import server_status
|
|
84
|
+
|
|
85
|
+
return server_status(args)
|
|
86
|
+
case "stop":
|
|
87
|
+
from .commands import stop_server
|
|
88
|
+
|
|
89
|
+
return stop_server(args)
|
|
90
|
+
case "update":
|
|
91
|
+
from .commands import update_projects
|
|
92
|
+
|
|
93
|
+
return update_projects(args)
|
|
94
|
+
case "whitelist_add":
|
|
95
|
+
from .commands import whitelist_add
|
|
96
|
+
|
|
97
|
+
return whitelist_add(args)
|
|
98
|
+
case "whitelist_list":
|
|
99
|
+
from .commands import whitelist_list
|
|
100
|
+
|
|
101
|
+
return whitelist_list(args)
|
|
102
|
+
case "whitelist_remove":
|
|
103
|
+
from .commands import whitelist_remove
|
|
104
|
+
|
|
105
|
+
return whitelist_remove(args)
|
|
106
|
+
case _:
|
|
107
|
+
import logging
|
|
108
|
+
|
|
109
|
+
logger = logging.getLogger(__name__)
|
|
110
|
+
|
|
111
|
+
logger.error(f"Unknown command: {command_name}")
|
|
112
|
+
return 1
|
|
111
113
|
|
|
114
|
+
|
|
115
|
+
def main() -> int:
|
|
116
|
+
# Parser Setup
|
|
112
117
|
parser = argparse.ArgumentParser(
|
|
113
118
|
prog="mcserver",
|
|
114
119
|
description="A CLI tool for managing Minecraft: Java Edition servers.",
|
|
@@ -134,28 +139,6 @@ def main() -> int:
|
|
|
134
139
|
|
|
135
140
|
commands = parser.add_subparsers(title="Commands")
|
|
136
141
|
|
|
137
|
-
# 'add' command
|
|
138
|
-
add_command = commands.add_parser(
|
|
139
|
-
"add",
|
|
140
|
-
help="Add Modrinth projects to the server",
|
|
141
|
-
description="Add Modrinth mods/plugins to the server",
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
add_command.set_defaults(command_name="add")
|
|
145
|
-
add_command.add_argument(
|
|
146
|
-
"projects", nargs="+", type=str, help="Modrinth project slugs or IDs"
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
# 'import' command
|
|
150
|
-
import_command = commands.add_parser(
|
|
151
|
-
"import",
|
|
152
|
-
help="Import a Modrinth modpack",
|
|
153
|
-
description="Import a Modrinth modpack from a file.",
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
import_command.set_defaults(command_name="import")
|
|
157
|
-
import_command.add_argument("file", type=str, help="The Modrinth modpack file")
|
|
158
|
-
|
|
159
142
|
# 'init' command
|
|
160
143
|
init_command = commands.add_parser(
|
|
161
144
|
"init",
|
|
@@ -193,15 +176,15 @@ def main() -> int:
|
|
|
193
176
|
init_command.add_argument(
|
|
194
177
|
"--min-ram",
|
|
195
178
|
default=512,
|
|
196
|
-
type=bound_int(
|
|
197
|
-
help="Minimum RAM for the server (in MebiBytes) (minimum value:
|
|
179
|
+
type=bound_int(512),
|
|
180
|
+
help="Minimum RAM for the server (in MebiBytes) (minimum value: 512)",
|
|
198
181
|
metavar="Size",
|
|
199
182
|
)
|
|
200
183
|
|
|
201
184
|
init_command.add_argument(
|
|
202
185
|
"--max-ram",
|
|
203
|
-
default=
|
|
204
|
-
type=
|
|
186
|
+
default=1024,
|
|
187
|
+
type=bound_int(1024),
|
|
205
188
|
help="Maximum RAM for the server (in MebiBytes) (minimum value: 1024)",
|
|
206
189
|
metavar="Size",
|
|
207
190
|
)
|
|
@@ -222,16 +205,9 @@ def main() -> int:
|
|
|
222
205
|
choices=search_sort_index,
|
|
223
206
|
help="Default search sort index",
|
|
224
207
|
metavar="Index",
|
|
225
|
-
dest="
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
# 'list' command
|
|
229
|
-
list_command = commands.add_parser(
|
|
230
|
-
"list", help="List all added projects", description="List all added projects."
|
|
208
|
+
dest="sort_index",
|
|
231
209
|
)
|
|
232
210
|
|
|
233
|
-
list_command.set_defaults(command_name="list")
|
|
234
|
-
|
|
235
211
|
# 'op' command
|
|
236
212
|
op_command = commands.add_parser(
|
|
237
213
|
"op", help="Manage operator players", description="Manage the operator status."
|
|
@@ -248,16 +224,6 @@ def main() -> int:
|
|
|
248
224
|
|
|
249
225
|
op_list_command.set_defaults(command_name="op_list")
|
|
250
226
|
|
|
251
|
-
# 'remove' command
|
|
252
|
-
remove_command = commands.add_parser(
|
|
253
|
-
"remove", help="Remove projects", description="Remove projects"
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
remove_command.set_defaults(command_name="remove")
|
|
257
|
-
remove_command.add_argument(
|
|
258
|
-
"projects", nargs="+", type=str, help="Modrinth project slugs or IDs"
|
|
259
|
-
)
|
|
260
|
-
|
|
261
227
|
# 'search' command
|
|
262
228
|
search_command = commands.add_parser(
|
|
263
229
|
"search",
|
|
@@ -272,7 +238,6 @@ def main() -> int:
|
|
|
272
238
|
|
|
273
239
|
search_command.add_argument(
|
|
274
240
|
"--limit",
|
|
275
|
-
default=20,
|
|
276
241
|
type=bound_int(1, 100),
|
|
277
242
|
help="Search projects per page (value between (inclusive): 1-100)",
|
|
278
243
|
metavar="Number",
|
|
@@ -289,13 +254,11 @@ def main() -> int:
|
|
|
289
254
|
)
|
|
290
255
|
|
|
291
256
|
search_command.add_argument(
|
|
292
|
-
"--sort",
|
|
293
|
-
default="relevance",
|
|
257
|
+
"--sort-index",
|
|
294
258
|
type=str,
|
|
295
259
|
choices=search_sort_index,
|
|
296
260
|
help="Sort by index",
|
|
297
261
|
metavar="Index",
|
|
298
|
-
dest="sort_index",
|
|
299
262
|
)
|
|
300
263
|
|
|
301
264
|
search_command.add_argument(
|
|
@@ -348,6 +311,7 @@ def main() -> int:
|
|
|
348
311
|
|
|
349
312
|
stop_command.set_defaults(command_name="stop")
|
|
350
313
|
|
|
314
|
+
# update is not going to be implemented in this version
|
|
351
315
|
# 'whitelist' command
|
|
352
316
|
whitelist_command = commands.add_parser(
|
|
353
317
|
"whitelist",
|
|
@@ -368,5 +332,15 @@ def main() -> int:
|
|
|
368
332
|
|
|
369
333
|
whitelist_list_command.set_defaults(command_name="whitelist_list")
|
|
370
334
|
|
|
335
|
+
# 'whitelist remove'
|
|
336
|
+
whitelist_remove_command = whitelist_subcommands.add_parser(
|
|
337
|
+
"remove",
|
|
338
|
+
help="Remove players from the whitelist",
|
|
339
|
+
description="List all whitelisted players.",
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
whitelist_remove_command.set_defaults(command_name="whitelist_remove")
|
|
343
|
+
whitelist_remove_command.add_argument("players", nargs="+", type=str, help="List of player names or UUIDs")
|
|
344
|
+
|
|
371
345
|
args = parser.parse_args()
|
|
372
346
|
return args.func(args)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from .add_projects import run as add_projects
|
|
2
|
+
from .import_setup import run as import_setup
|
|
3
|
+
from .initialize_server import run as initialize_server
|
|
4
|
+
from .list_projects import run as list_projects
|
|
5
|
+
from .op_grant import run as op_grant
|
|
6
|
+
from .op_list import run as op_list
|
|
7
|
+
from .op_revoke import run as op_revoke
|
|
8
|
+
from .print_help import run as print_help
|
|
9
|
+
from .remove_projects import run as remove_projects
|
|
10
|
+
from .search_projects import run as search_projects
|
|
11
|
+
from .server_status import run as server_status
|
|
12
|
+
from .show_projects import run as show_projects
|
|
13
|
+
from .start_server import run as start_server
|
|
14
|
+
from .stop_server import run as stop_server
|
|
15
|
+
from .update_projects import run as update_projects
|
|
16
|
+
from .whitelist_add import run as whitelist_add
|
|
17
|
+
from .whitelist_list import run as whitelist_list
|
|
18
|
+
from .whitelist_remove import run as whitelist_remove
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"add_projects",
|
|
22
|
+
"import_setup",
|
|
23
|
+
"initialize_server",
|
|
24
|
+
"list_projects",
|
|
25
|
+
"op_grant",
|
|
26
|
+
"op_list",
|
|
27
|
+
"op_revoke",
|
|
28
|
+
"print_help",
|
|
29
|
+
"remove_projects",
|
|
30
|
+
"search_projects",
|
|
31
|
+
"server_status",
|
|
32
|
+
"show_projects",
|
|
33
|
+
"start_server",
|
|
34
|
+
"stop_server",
|
|
35
|
+
"update_projects",
|
|
36
|
+
"whitelist_add",
|
|
37
|
+
"whitelist_list",
|
|
38
|
+
"whitelist_remove",
|
|
39
|
+
]
|