Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
WIP #60 rename to option --dry-run on run subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjabear committed Sep 29, 2016
1 parent cd803c6 commit d5fb492
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ const USAGE: &'static str = "
Factotum.
Usage:
factotum run <factfile> [--start=<start_task>] [--env=<env>]
factotum dry-run <factfile> [--start=<start_task>] [--env=[env]]
factotum run <factfile> [--start=<start_task>] [--env=<env>] [--dry-run]
factotum validate <factfile>
factotum (-h | --help)
Options:
-h --help Show this screen.
--start=<start_task> Begin at specified task.
--env=<env> Supply JSON to define mustache variables in Factfile.
--dry-run Pretend to execute a Factfile, showing the commands that would be executed. Can be used with other options.
";

#[derive(Debug, RustcDecodable)]
struct Args {
flag_start: Option<String>,
flag_env: Option<String>,
flag_dry_run: bool,
arg_factfile: String,
cmd_run: bool,
cmd_validate: bool,
cmd_dry_run: bool
cmd_validate: bool
}

// macro to simplify printing to stderr
Expand Down Expand Up @@ -374,9 +374,11 @@ fn factotum() -> i32 {
};

if args.cmd_run {
parse_file_and_execute(&args.arg_factfile, args.flag_env, args.flag_start)
} else if args.cmd_dry_run {
parse_file_and_simulate(&args.arg_factfile, args.flag_env, args.flag_start)
if !args.flag_dry_run {
parse_file_and_execute(&args.arg_factfile, args.flag_env, args.flag_start)
} else {
parse_file_and_simulate(&args.arg_factfile, args.flag_env, args.flag_start)
}
} else if args.cmd_validate {
match validate(&args.arg_factfile, args.flag_env) {
Ok(msg) => {
Expand Down

0 comments on commit d5fb492

Please sign in to comment.