Anki/build/runner/src/rsync.rs
Damien Elmes ded805b504
Switch Rust import style (#2330)
* Prepare to switch Rust import style

* Run nightly format

Closes #2320

* Clean up a few imports

* Enable comment wrapping

* Wrap comments
2023-01-18 21:39:55 +10:00

40 lines
1 KiB
Rust

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::process::Command;
use camino::Utf8Path;
use clap::Args;
use crate::paths::absolute_msys_path;
use crate::run::run_silent;
#[derive(Args)]
pub struct RsyncArgs {
#[arg(long, value_delimiter(','), allow_hyphen_values(true))]
extra_args: Vec<String>,
#[arg(long)]
prefix: String,
#[arg(long, required(true), num_args(..))]
inputs: Vec<String>,
#[arg(long)]
output_dir: String,
}
pub fn rsync_files(args: RsyncArgs) {
let output_dir = absolute_msys_path(Utf8Path::new(&args.output_dir));
run_silent(
Command::new("rsync")
.current_dir(&args.prefix)
.arg("--relative")
.args(args.extra_args)
.args(args.inputs.iter().map(|i| {
if cfg!(windows) {
i.replace('\\', "/")
} else {
i.clone()
}
}))
.arg(output_dir),
);
}