From 193c2fb8959014de499ff77ec2509b4523268c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 18 Jan 2020 07:55:22 -0700 Subject: Implement --target-dir --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') 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 { @@ -25,7 +30,8 @@ fn collect_source_files() -> Vec { 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::().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"); -- cgit v1.2.3