diff options
author | Ondřej Čertík <ondrej@certik.us> | 2020-01-18 09:50:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-18 09:50:08 -0700 |
commit | af56c5890cd28f051147e36fa3c1d8553ec944ea (patch) | |
tree | 867ddd932e22403bea6fd477ceb5036281326e4a | |
parent | 494fdda13db2944bda8e8c7e92ace6b65d448204 (diff) | |
parent | 193c2fb8959014de499ff77ec2509b4523268c8c (diff) | |
download | fpm-af56c5890cd28f051147e36fa3c1d8553ec944ea.tar.gz fpm-af56c5890cd28f051147e36fa3c1d8553ec944ea.zip |
Merge pull request #23 from certik/target_dir
Implement --target-dir
-rw-r--r-- | src/main.rs | 12 | ||||
-rw-r--r-- | tests/cli.rs | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 3fa2917..eeb118b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,15 @@ use structopt::StructOpt; use toml::Value; +use std::path::{Path, PathBuf}; #[derive(Debug, StructOpt)] struct Cli { /// fpm command command: String, + + /// Directory for all generated artifacts + #[structopt(long, name="DIRECTORY", default_value = "target")] + target_dir : PathBuf, } fn collect_source_files() -> Vec<String> { @@ -25,7 +30,8 @@ fn collect_source_files() -> Vec<String> { files } -fn build() { +fn build(target_dir: &Path) { + println!("TARGET_DIR: {}", target_dir.to_str().unwrap()); let value = std::fs::read_to_string("fpm.toml") .unwrap() .parse::<Value>().unwrap(); @@ -98,10 +104,10 @@ fn main() { println!("{:?}", args); if args.command == "build" { println!("Command: build"); - build(); + build(args.target_dir.as_path()); } else if args.command == "run" { println!("Command: run"); - build(); + build(args.target_dir.as_path()); run(); } else { panic!("Unknown command"); diff --git a/tests/cli.rs b/tests/cli.rs index 2d32e4d..3573113 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -58,6 +58,8 @@ fn test_help() { fn test_1() { let mut build = Command::cargo_bin("fpm").unwrap(); build.arg("build") + .arg("--target-dir") + .arg("build-test") .current_dir("tests/1"); build.assert() .success2() @@ -76,6 +78,8 @@ fn test_1() { fn test_2() { let mut build = Command::cargo_bin("fpm").unwrap(); build.arg("build") + .arg("--target-dir") + .arg("build-test") .current_dir("tests/2"); build.assert() .success2() |