添加命令行工具

This commit is contained in:
远野千束 2024-10-03 00:22:04 +08:00
parent 703fe75a76
commit 851242ce51
2 changed files with 7 additions and 3 deletions

View File

@ -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

View File

@ -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()