allow to pass multiple arguments/options to remote cargo

pull/1/head
Sebastian Geisler 7 years ago
parent 670b578371
commit 161dc22cfc

@ -1,3 +1,5 @@
#![feature(attr_literals)]
extern crate structopt;
#[macro_use]
extern crate structopt_derive;
@ -16,6 +18,7 @@ use std::io::Read;
use std::borrow::Borrow;
use structopt::StructOpt;
use structopt::clap::AppSettings;
use toml::Value;
@ -24,9 +27,6 @@ use toml::Value;
enum Opts {
#[structopt(name = "remote")]
Remote {
#[structopt(help = "cargo command that will be executed remotely")]
command: String,
#[structopt(short = "r", long = "remote", help = "remote ssh build server")]
remote: Option<String>,
@ -50,13 +50,19 @@ enum Opts {
help = "transfer hidden files and directories to the build server"
)]
hidden: bool,
#[structopt(
help = "cargo command and flags that will be executed remotely",
min_values = 1
)]
command: Vec<String>,
}
}
fn main() {
simple_logger::init().unwrap();
let Opts::Remote{command, remote, copy_back, manifest_path, hidden} = Opts::from_args();
let Opts::Remote{remote, copy_back, manifest_path, hidden, command} = Opts::from_args();
let manifest_path = manifest_path.as_ref().map(PathBuf::borrow);
let project_metadata = cargo_metadata::metadata(manifest_path)
@ -125,7 +131,10 @@ fn main() {
let build_command = format!(
"cd ~/remote-builds/{}/; $HOME/.cargo/bin/cargo {}",
project_name,
command
command.iter().fold(
String::new(),
|acc, x| format!("{} {}", acc, x)
)
);
info!("Starting build process.");

Loading…
Cancel
Save