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

Commit

Permalink
Add version command (closes #36)
Browse files Browse the repository at this point in the history
Usage: factotum -v or factotum --version.

The version is baked in, and taken from the project's Cargo.toml
  • Loading branch information
ninjabear committed Sep 30, 2016
1 parent 2536f98 commit f5bf708
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const PROC_PARSE_ERROR: i32 = 1;
const PROC_EXEC_ERROR: i32 = 2;
const PROC_OTHER_ERROR: i32 = 3;

const VERSION: &'static str = env!("CARGO_PKG_VERSION");
const USAGE: &'static str = "
Factotum.
Expand All @@ -53,9 +54,11 @@ Usage:
factotum validate <factfile>
factotum dot <factfile> [--start=<start_task>] [--output=<output_file>] [--overwrite]
factotum (-h | --help)
factotum (-v | --version)
Options:
-h --help Show this screen.
-v --version Display the version of Factotum and exit.
--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.
Expand All @@ -71,6 +74,7 @@ struct Args {
flag_overwrite: bool,
flag_dry_run: bool,
arg_factfile: String,
flag_version: bool,
cmd_run: bool,
cmd_validate: bool,
cmd_dot: bool
Expand Down Expand Up @@ -408,6 +412,11 @@ fn factotum() -> i32 {
return PROC_OTHER_ERROR
}
};

if args.flag_version {
println!("Factotum version {}", VERSION);
return PROC_SUCCESS
}

if args.cmd_run {
if !args.flag_dry_run {
Expand Down

0 comments on commit f5bf708

Please sign in to comment.