From 06a77aada3b5d4c724675037c7f802dcfddc4115 Mon Sep 17 00:00:00 2001 From: blob42 Date: Mon, 21 Aug 2023 13:54:14 +0200 Subject: [PATCH] update rcargo --- rcargo | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rcargo b/rcargo index a15272d..f5c1ee6 100755 --- a/rcargo +++ b/rcargo @@ -36,7 +36,7 @@ ERR_CMD = 1 ERR_DEPENDENCY = 2 #TODO: binary and package names might differ: use `cargo install --list to extract bin name` -def inst_get_binary(conn, package, debug=False): +def inst_get_binary(conn: Connection, package: str, debug: bool = False) -> None: find_bin = f'cargo install --list | grep -A1 {package} | sed -nE "s/ *//; 2 p"' bin_name = '' try: @@ -52,9 +52,13 @@ def inst_get_binary(conn, package, debug=False): local_path = Path(LOCAL_BIN_PATH).expanduser().__str__()+'/' try: - get_remote_bin = conn.get(bin_path, local=local_path) + if os.path.exists(bin_path): + os.remove(bin_path) + conn.get(bin_path, local=local_path) except FileNotFoundError as e: print('could not copy installed package {} from remote'.format(package)) + sys.exit(ERR_CMD) + print(f'installed [bold blue]{bin_name}[/bold blue] at {LOCAL_BIN_PATH}')