diff --git a/cd/__init__.py b/cd/__init__.py index a23ea49..e85220a 100644 --- a/cd/__init__.py +++ b/cd/__init__.py @@ -83,7 +83,7 @@ def cat(file: str) -> None: shut(file) -def install_commands(path) -> None: +def install_commands(path: str) -> None: step("Install commands") user = Path("/usr/local/bin") for command in [ @@ -94,7 +94,7 @@ def install_commands(path) -> None: "synchronize", ]: print(command) - os.symlink(path, user / f"{COMMANDS_PREFIX}{command}") + (user / f"{COMMANDS_PREFIX}{command}").symlink_to(path) def set_ssh(*arguments) -> None: diff --git a/cd/__main__.py b/cd/__main__.py index 891e6aa..774fbe5 100755 --- a/cd/__main__.py +++ b/cd/__main__.py @@ -6,12 +6,11 @@ from pathlib import Path import cd if __name__ == "__main__": - command, *arguments = sys.argv - command = Path(command).name - if command == "__main__.py": + path, *arguments = sys.argv + name = Path(path).name + if name == "__main__.py": cd.set_ssh(*arguments) cd.install_commands(__file__) else: - command = command.replace("-", "_") - function = getattr(cd, command) + function = getattr(cd, name.replace("-", "_")) function(*arguments)