diff options
| author | Daniel Weipert <git@mail.dweipert.de> | 2026-04-10 14:10:11 +0200 |
|---|---|---|
| committer | Daniel Weipert <git@mail.dweipert.de> | 2026-04-10 14:10:11 +0200 |
| commit | e42e24281c3714d864a6f0965c4d8e6476fa0ee0 (patch) | |
| tree | 3e77b1735fc566b0d565b0b874b90b1737b34677 | |
| parent | ff750baf52a91582d53eaccb76e09318a51cafa7 (diff) | |
add copy command
| -rwxr-xr-x | rclone-ide | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -203,6 +203,36 @@ def command_set_default_remote(options: Mapping[str, Any]) -> None: subprocess.run(cmd) +def command_copy(options: Mapping[str, Any]) -> None: + """Copy files to remote""" + + remote_config = get_remote_config(options.remote) + + local_path = build_cmd_local_path(remote_config["config"]) + + # build path to directory for local and remote + local_directory_path = options.directory + if options.directory: + if not os.path.exists(os.join(os.getcwd(), local_path, options.directory)): + raise FileNotFoundError("Local directory missing") + + cmd = [ + "rclone", "copy", + os.path.join(local_path, local_directory_path).rstrip("/"), + os.path.join( + build_cmd_remote_path(remote_config["remote"], remote_config["config"]), + local_directory_path, + ).rstrip("/"), + build_cmd_config(), + *build_cmd_logging(), + ] + + if options.dry_run: + print(" ".join(cmd)) + else: + subprocess.run(cmd) + + def command_copy_file(options: Mapping[str, Any]) -> None: """Copy specific file to remote""" @@ -256,6 +286,11 @@ parser_set_default_remote = subparsers.add_parser("set-default-remote") parser_set_default_remote.add_argument("remote", choices=config.keys()) +parser_copy_file = subparsers.add_parser("copy") +parser_copy_file.add_argument("remote", help="rclone remote to upload to. @ = default remote", choices=[*config.keys(), "@"]) +parser_copy_file.add_argument("directory", help="cwd-relative path to directory", nargs="?", default="") + + parser_copy_file = subparsers.add_parser("copy-file") parser_copy_file.add_argument("remote", help="rclone remote to upload to. @ = default remote", choices=[*config.keys(), "@"]) parser_copy_file.add_argument("filepath", help="cwd-relative path to file") @@ -272,7 +307,11 @@ if args.command: command_set_remote_path(args) case "set-default-remote": command_set_default_remote(args) + + case "copy": + command_copy(args) + case "copy-file": command_copy_file(args) |
