diff --git a/dev-tools/entrypoint.py b/dev-tools/entrypoint-cli.py similarity index 100% rename from dev-tools/entrypoint.py rename to dev-tools/entrypoint-cli.py diff --git a/dev-tools/entrypoint-pip.py b/dev-tools/entrypoint-pip.py new file mode 100644 index 0000000..e638dff --- /dev/null +++ b/dev-tools/entrypoint-pip.py @@ -0,0 +1,20 @@ +import os + +os.chdir(os.path.dirname(os.path.abspath(__file__))) +os.environ["DUETECTOR_LOG_LEVEL"] = "DEBUG" + +import re +import sys +from pathlib import Path + +from pkg_resources import load_entry_point + +db_file = Path("./duetector-dbcollector.sqlite3") +config_file = Path("./config.toml") + +if __name__ == "__main__": + db_file.unlink(missing_ok=True) + sys.argv[0] = re.sub(r"(-script\.pyw?|\.exe)?$", "", sys.argv[0]) + sys.argv.append("start") + sys.argv.extend(["--config", config_file.resolve().as_posix()]) + sys.exit(load_entry_point("duetector", "console_scripts", "duectl")()) diff --git a/duetector/cli/server.py b/duetector/cli/server.py new file mode 100644 index 0000000..7d62df1 --- /dev/null +++ b/duetector/cli/server.py @@ -0,0 +1,18 @@ +import click + + +@click.command() +def start(): + click.echo("start") + + +@click.group() +def cli(): + pass + + +cli.add_command(start) + + +if __name__ == "__main__": + cli(["start"]) diff --git a/pyproject.toml b/pyproject.toml index 135da34..0fcf17f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ docs = ["Sphinx<=7.2.4", "sphinx-rtd-theme", "sphinx-click", "autodoc_pydantic"] [project.scripts] duectl = "duetector.cli.main:cli" duectl-daemon = "duetector.cli.daemon:cli" - +duectl-server = "duetector.cli.server:cli" [[project.authors]] name = "hitsz-ids"