diff --git a/pyproject.toml b/pyproject.toml index a3606f2..4de0e92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ requires = ["pdm-backend"] build-backend = "pdm.backend" [project.scripts] -server-status = "server_status.__main__" +server-status = "server_status.__main__:main" [tool.pdm] distribution = true diff --git a/server_status/__main__.py b/server_status/__main__.py index a4b3ac8..89ed3ee 100644 --- a/server_status/__main__.py +++ b/server_status/__main__.py @@ -1,10 +1,10 @@ -import socket import sys from server_status.api import * from server_status.cmd_parser import server_status_alc -if __name__ == "__main__": + +def main(): raw_msg = "server_status " + " ".join(sys.argv[1:]) arp = server_status_alc.parse(raw_msg) @@ -35,3 +35,7 @@ if __name__ == "__main__": else: log("Unknown command, use 'server_status --help' for help/未知命令或参数错误,请使用 'server_status --help' 获取帮助") + + +if __name__ == "__main__": + main()