Align with xiaohe wheel deploy so VPS installs carry a clear package version.
76 lines
2.0 KiB
Python
76 lines
2.0 KiB
Python
"""MyCLI main entry point."""
|
|
|
|
from pathlib import Path
|
|
|
|
import click
|
|
|
|
from mytoolkit.commands import pdf, image, latex, video, bib, voice, docx, paper
|
|
from mytoolkit.commands.convert import convert_cmd
|
|
from mytoolkit.commands.env import env_cmd
|
|
from mytoolkit.commands.templates import templates_cmd
|
|
from mytoolkit.commands.init import init_cmd
|
|
from mytoolkit.commands.info import info_cmd
|
|
from mytoolkit.commands.ssh import ssh_cmd
|
|
from mytoolkit.commands.git import git_cmd
|
|
from mytoolkit.commands.server import server_cmd
|
|
from mytoolkit.commands.webpage import webpage_cmd
|
|
from mytoolkit.commands.mycv import mycv_cmd
|
|
from mytoolkit.commands.mail import mail
|
|
from mytoolkit.commands.completion import build_completion_group
|
|
from mytoolkit.commands.completion_install import ensure_completions_installed
|
|
from mytoolkit.commands.self_mgmt import update_cmd, uninstall_cmd
|
|
|
|
|
|
def _cli_version() -> str:
|
|
try:
|
|
from importlib.metadata import version
|
|
|
|
return version("mytoolkit")
|
|
except Exception:
|
|
return "0.2.0"
|
|
|
|
|
|
@click.group()
|
|
@click.version_option(version=_cli_version(), prog_name="mytoolkit")
|
|
def cli():
|
|
"""Personal CLI toolkit."""
|
|
pass
|
|
|
|
|
|
# Register command groups
|
|
cli.add_command(convert_cmd)
|
|
cli.add_command(pdf.pdf)
|
|
cli.add_command(docx.docx)
|
|
cli.add_command(image.image)
|
|
cli.add_command(voice.voice)
|
|
cli.add_command(latex.latex)
|
|
cli.add_command(video.video)
|
|
cli.add_command(bib.bib)
|
|
cli.add_command(paper.paper)
|
|
cli.add_command(env_cmd)
|
|
cli.add_command(templates_cmd)
|
|
cli.add_command(init_cmd)
|
|
cli.add_command(info_cmd)
|
|
cli.add_command(ssh_cmd)
|
|
cli.add_command(git_cmd)
|
|
cli.add_command(server_cmd)
|
|
cli.add_command(webpage_cmd)
|
|
cli.add_command(mycv_cmd)
|
|
cli.add_command(mail)
|
|
cli.add_command(update_cmd)
|
|
cli.add_command(uninstall_cmd)
|
|
cli.add_command(build_completion_group(lambda: cli))
|
|
|
|
|
|
def main():
|
|
import sys
|
|
|
|
argv = sys.argv[1:]
|
|
if not argv or argv[0] != "completion":
|
|
ensure_completions_installed(cli)
|
|
cli.main(args=argv, prog_name="mytoolkit", standalone_mode=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|