diff options
author | Ondřej Čertík <ondrej@certik.us> | 2020-01-18 07:55:22 -0700 |
---|---|---|
committer | Ondřej Čertík <ondrej@certik.us> | 2020-01-18 07:55:22 -0700 |
commit | 193c2fb8959014de499ff77ec2509b4523268c8c (patch) | |
tree | 867ddd932e22403bea6fd477ceb5036281326e4a /src/main.rs | |
parent | 494fdda13db2944bda8e8c7e92ace6b65d448204 (diff) | |
download | fpm-193c2fb8959014de499ff77ec2509b4523268c8c.tar.gz fpm-193c2fb8959014de499ff77ec2509b4523268c8c.zip |
Implement --target-dir
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 9 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"); |