From 0702fae0e900b68c2bce6e99d0249d8fd6f23aa8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 21 Jun 2024 12:10:09 +0200 Subject: [PATCH] main --- cd/__init__.py | 13 +++++++++++++ cd/__main__.py | 12 +----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/cd/__init__.py b/cd/__init__.py index ca3b9c8..9d776e7 100644 --- a/cd/__init__.py +++ b/cd/__init__.py @@ -3,12 +3,14 @@ __version__ = "0.0.1" import os +import sys from pathlib import Path import env from rwx import fs, ps from rwx.log import stream as log +import cd from cd.project import Project from cd.projects import Projects @@ -113,6 +115,17 @@ def install_commands(path: str) -> None: (user / f"{COMMANDS_PREFIX}{command}").symlink_to(path) +def main() -> None: + path, *arguments = sys.argv + name = Path(path).name + if name == "__main__.py": + cd.set_ssh(*arguments) + cd.install_commands(__file__) + else: + function = getattr(cd, name.replace("-", "_")) + function(*arguments) + + def set_ssh(*arguments: str) -> None: step("Set SSH") # diff --git a/cd/__main__.py b/cd/__main__.py index 520006a..bfad99f 100755 --- a/cd/__main__.py +++ b/cd/__main__.py @@ -2,17 +2,7 @@ """Entry point to either bootstrap or command.""" -import sys -from pathlib import Path - import cd if __name__ == "__main__": - path, *arguments = sys.argv - name = Path(path).name - if name == "__main__.py": - cd.set_ssh(*arguments) - cd.install_commands(__file__) - else: - function = getattr(cd, name.replace("-", "_")) - function(*arguments) + cd.main(__file__)