diff options
-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() |