diff --git a/readme.md b/readme.md index 1d9164f..f1d63a1 100644 --- a/readme.md +++ b/readme.md @@ -14,7 +14,29 @@ The only requirement for using this is Docker. The application is written in Pyt ### Install -After that, download the right executible for you in the [Releases Page](https://github.com/oitsjustjose/DMSM/releases), move it to wherever you keep things (like `/usr/local/bin` for unix-based systems) +An installer has been created for Unix-based users which can be found on the [Releases Page](https://github.com/oitsjustjose/DMSM/releases). Once downloaded, run it as root. + +### Usage + +**Create** + +`dmsm create -p -r -v <...OTHER_FLAGS>` + +You can find all flags individually detailed (by hand 😓), within [flags.md](https://github.com/oitsjustjose/DMSM/blob/main/flags.md) + +**Start**: `dmsm start ` + +**Stop**: `dmsm stop [-f|--force]` + +**Restart**: `dmsm restart [-f|--force]` + +**Delete**: `dmsm delete ` + +**Status**: `dmsm status ` + +**Console**: `dmsm console ` + +**Logs**: `dmsm logs ` ## Building @@ -28,4 +50,4 @@ All you have to do once you have the dependencies handled is to run `python3 -m ## Running -The CLI will help you do this -- give me a bit and I'll write up more docs on this! +The CLI will help you do this -- give me a bit and I'll write up more docs on this! \ No newline at end of file diff --git a/src/args.py b/src/args.py index a8e1e64..a8e8994 100644 --- a/src/args.py +++ b/src/args.py @@ -28,9 +28,6 @@ def get_args() -> argparse.Namespace: if len(sys.argv) >= 2 and sys.argv[1] == "create": _create(parser) - if len(sys.argv) >= 2 and sys.argv[1] in ["stop", "restart"]: - _stop_restart(parser) - if not _validate(parser): sys.exit(1) @@ -49,19 +46,6 @@ def _validate(parser: argparse.ArgumentParser) -> bool: return True -def _stop_restart(parser: argparse.ArgumentParser): - """ - Handles adding the stop/restart arguments - """ - parser.add_argument( - "-f", - "--force", - help="Will forcibly shut down the server", - action="store_true", - required=False, - ) - - def _create(parser: argparse.ArgumentParser): """ Handles adding the create arguments diff --git a/src/dmsm.py b/src/dmsm.py index cda5213..bd6d3bf 100644 --- a/src/dmsm.py +++ b/src/dmsm.py @@ -25,15 +25,17 @@ def main(args: Namespace) -> None: elif action == "start": mgr.start_server() elif action == "stop": - mgr.stop_server(force=args.force) + mgr.stop_server(force="-f" in sys.argv or "--force" in sys.argv) elif action == "restart": - mgr.restart_server(force=args.force) + mgr.restart_server(force="-f" in sys.argv or "--force" in sys.argv) elif action == "delete": mgr.delete_server() elif action == "status": mgr.get_status() elif action == "console": mgr.open_console() + elif action == "logs": + mgr.logs() if __name__ == "__main__": diff --git a/src/docker_mgr.py b/src/docker_mgr.py index 8f2c232..baa972b 100644 --- a/src/docker_mgr.py +++ b/src/docker_mgr.py @@ -188,4 +188,11 @@ class ServerManager: """ Connects the user to the server's console """ + os.system(f"docker exec -it {self._name} cat logs/latest.log") os.system(f"docker exec -i {self._name} rcon-cli") + + def logs(self): + """ + Shows the latest logs for the server + """ + os.system(f"docker exec -it {self._name} cat logs/latest.log")