allow setting custom local binary path

master
blob42 2 years ago
parent 2cf1adf61b
commit 1ec5a06b18

@ -27,6 +27,7 @@ log = logging.getLogger('rcargo')
CARGO_BIN_PATH='~/.cargo/bin/' CARGO_BIN_PATH='~/.cargo/bin/'
LOCAL_BIN_PATH=''
DEPS = [ DEPS = [
'rsync' 'rsync'
] ]
@ -47,18 +48,19 @@ def inst_get_binary(conn, package, debug=False):
except Exception as e: except Exception as e:
raise e raise e
bin_path = Path(CARGO_BIN_PATH, bin_name).expanduser() bin_path = Path(LOCAL_BIN_PATH, bin_name).expanduser()
local_path = Path(CARGO_BIN_PATH).expanduser().__str__()+'/' local_path = Path(LOCAL_BIN_PATH).expanduser().__str__()+'/'
try: try:
get_remote_bin = conn.get(bin_path, local=local_path) get_remote_bin = conn.get(bin_path, local=local_path)
except FileNotFoundError as e: except FileNotFoundError as e:
print('could not copy installed package {} from remote'.format(package)) print('could not copy installed package {} from remote'.format(package))
print(f'installed [bold blue]{bin_name}[/bold blue] at {CARGO_BIN_PATH}') print(f'installed [bold blue]{bin_name}[/bold blue] at {LOCAL_BIN_PATH}')
def install(args): def install(args):
print(f'{LOCAL_BIN_PATH}')
package = args.package package = args.package
conn = Connection(args.host) conn = Connection(args.host)
@ -89,10 +91,11 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description='remote rust cargo commands') parser = argparse.ArgumentParser(description='remote rust cargo commands')
parser.add_argument('-H', '--host', default=default_host) parser.add_argument('-H', '--host', default=default_host)
parser.add_argument('-d', '--debug', action='store_true') parser.add_argument('-d', '--debug', action='store_true')
#TODO: use a dynamic positional argument, we can pass anything to cargo parser.add_argument('-b', '--bin-path',
#TODO: it will be tried on the remote cargo and raise error if it does default=CARGO_BIN_PATH,
#TODO: not exist. To do special handling (like install) just watch the help='local path for installed binary',
#TODO: argument value metavar='')
subparsers = parser.add_subparsers(dest='command') subparsers = parser.add_subparsers(dest='command')
install_parser = subparsers.add_parser('install', help='install packages from crates.io with remote build') install_parser = subparsers.add_parser('install', help='install packages from crates.io with remote build')
@ -102,6 +105,7 @@ if __name__ == '__main__':
build = subparsers.add_parser('build', help='remote build local cargo package') build = subparsers.add_parser('build', help='remote build local cargo package')
args = parser.parse_args() args = parser.parse_args()
LOCAL_BIN_PATH = args.bin_path
if args.debug: if args.debug:
log.setLevel('INFO') log.setLevel('INFO')
if args.host == 'localhost': if args.host == 'localhost':

Loading…
Cancel
Save