2017-11-16 23:30:08 -08:00
|
|
|
use common::*;
|
2016-10-23 16:43:52 -07:00
|
|
|
|
2017-11-30 15:03:59 -08:00
|
|
|
use std::{convert, ffi, cmp};
|
2017-11-16 23:30:08 -08:00
|
|
|
use clap::{App, Arg, ArgGroup, AppSettings};
|
|
|
|
use configuration::DEFAULT_SHELL;
|
2018-02-16 00:52:00 -08:00
|
|
|
use misc::maybe_s;
|
2017-11-30 15:03:59 -08:00
|
|
|
use unicode_width::UnicodeWidthStr;
|
2016-10-23 16:43:52 -07:00
|
|
|
|
2018-02-16 00:52:00 -08:00
|
|
|
#[cfg(windows)]
|
|
|
|
use ansi_term::enable_ansi_support;
|
|
|
|
|
2016-10-23 16:43:52 -07:00
|
|
|
macro_rules! die {
|
|
|
|
($($arg:tt)*) => {{
|
|
|
|
extern crate std;
|
2017-08-18 14:15:43 -07:00
|
|
|
eprintln!($($arg)*);
|
2017-04-21 22:11:18 -07:00
|
|
|
process::exit(EXIT_FAILURE)
|
2016-10-23 16:43:52 -07:00
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
2016-11-12 14:02:15 -08:00
|
|
|
fn edit<P: convert::AsRef<ffi::OsStr>>(path: P) -> ! {
|
|
|
|
let editor = env::var_os("EDITOR")
|
|
|
|
.unwrap_or_else(|| die!("Error getting EDITOR environment variable"));
|
|
|
|
|
2017-11-16 23:30:08 -08:00
|
|
|
let error = Command::new(editor)
|
2016-11-12 14:02:15 -08:00
|
|
|
.arg(path)
|
|
|
|
.status();
|
|
|
|
|
|
|
|
match error {
|
2017-04-21 22:11:18 -07:00
|
|
|
Ok(status) => process::exit(status.code().unwrap_or(EXIT_FAILURE)),
|
2016-11-12 14:02:15 -08:00
|
|
|
Err(error) => die!("Failed to invoke editor: {}", error),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-16 23:30:08 -08:00
|
|
|
trait Slurp {
|
|
|
|
fn slurp(&mut self) -> Result<String, io::Error>;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Slurp for fs::File {
|
|
|
|
fn slurp(&mut self) -> io::Result<String> {
|
|
|
|
let mut destination = String::new();
|
|
|
|
self.read_to_string(&mut destination)?;
|
|
|
|
Ok(destination)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn run() {
|
2018-05-01 14:01:59 -07:00
|
|
|
let matches = App::new(env!("CARGO_PKG_NAME"))
|
2016-11-10 23:09:02 -08:00
|
|
|
.version(concat!("v", env!("CARGO_PKG_VERSION")))
|
2017-05-09 17:31:30 -07:00
|
|
|
.author(env!("CARGO_PKG_AUTHORS"))
|
|
|
|
.about(concat!(env!("CARGO_PKG_DESCRIPTION"), " - ", env!("CARGO_PKG_HOMEPAGE")))
|
2017-11-17 23:59:36 -08:00
|
|
|
.help_message("Print help information")
|
|
|
|
.version_message("Print version information")
|
2016-11-07 21:05:07 -08:00
|
|
|
.setting(AppSettings::ColoredHelp)
|
2017-08-18 14:21:18 -07:00
|
|
|
.setting(AppSettings::TrailingVarArg)
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("ARGUMENTS")
|
2017-04-20 22:49:51 -07:00
|
|
|
.multiple(true)
|
|
|
|
.help("The recipe(s) to run, defaults to the first recipe in the justfile"))
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("COLOR")
|
2017-04-20 22:49:51 -07:00
|
|
|
.long("color")
|
|
|
|
.takes_value(true)
|
|
|
|
.possible_values(&["auto", "always", "never"])
|
|
|
|
.default_value("auto")
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("Print colorful output"))
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("DRY-RUN")
|
2017-04-20 22:49:51 -07:00
|
|
|
.long("dry-run")
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("Print what just would do without doing it")
|
2017-11-17 23:23:24 -08:00
|
|
|
.conflicts_with("QUIET"))
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("DUMP")
|
2016-11-11 20:25:37 -08:00
|
|
|
.long("dump")
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("Print entire justfile"))
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("EDIT")
|
2016-11-12 14:02:15 -08:00
|
|
|
.short("e")
|
|
|
|
.long("edit")
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("Open justfile with $EDITOR"))
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("EVALUATE")
|
2017-04-20 22:49:51 -07:00
|
|
|
.long("evaluate")
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("Print evaluated variables"))
|
2017-04-25 23:39:34 -07:00
|
|
|
.arg(Arg::with_name("HIGHLIGHT")
|
|
|
|
.long("highlight")
|
|
|
|
.help("Highlight echoed recipe lines in bold"))
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("JUSTFILE")
|
2017-09-10 22:56:17 -07:00
|
|
|
.short("f")
|
2017-04-20 22:49:51 -07:00
|
|
|
.long("justfile")
|
|
|
|
.takes_value(true)
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("Use <JUSTFILE> as justfile. --working-directory must also be set")
|
2017-04-20 23:24:23 -07:00
|
|
|
.requires("WORKING-DIRECTORY"))
|
|
|
|
.arg(Arg::with_name("LIST")
|
2017-04-20 22:49:51 -07:00
|
|
|
.short("l")
|
|
|
|
.long("list")
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("List available recipes and their arguments"))
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("QUIET")
|
2016-11-05 01:01:43 -07:00
|
|
|
.short("q")
|
|
|
|
.long("quiet")
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("Suppress all output")
|
2017-04-20 23:24:23 -07:00
|
|
|
.conflicts_with("DRY-RUN"))
|
|
|
|
.arg(Arg::with_name("SET")
|
2016-10-30 03:08:28 -07:00
|
|
|
.long("set")
|
|
|
|
.takes_value(true)
|
|
|
|
.number_of_values(2)
|
2017-04-20 23:24:23 -07:00
|
|
|
.value_names(&["VARIABLE", "VALUE"])
|
2016-10-30 03:08:28 -07:00
|
|
|
.multiple(true)
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("Set <VARIABLE> to <VALUE>"))
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("SHELL")
|
2017-04-20 23:06:03 -07:00
|
|
|
.long("shell")
|
|
|
|
.takes_value(true)
|
|
|
|
.default_value(DEFAULT_SHELL)
|
2017-04-20 23:24:23 -07:00
|
|
|
.help("Invoke <SHELL> to run recipes"))
|
|
|
|
.arg(Arg::with_name("SHOW")
|
2017-04-20 22:49:51 -07:00
|
|
|
.short("s")
|
|
|
|
.long("show")
|
2016-10-23 19:56:30 -07:00
|
|
|
.takes_value(true)
|
2017-04-20 23:24:23 -07:00
|
|
|
.value_name("RECIPE")
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("Show information about <RECIPE>"))
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("SUMMARY")
|
2017-04-20 22:49:51 -07:00
|
|
|
.long("summary")
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("List names of available recipes"))
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("VERBOSE")
|
|
|
|
.short("v")
|
|
|
|
.long("verbose")
|
2017-04-20 22:49:51 -07:00
|
|
|
.help("Use verbose output"))
|
2017-04-20 23:24:23 -07:00
|
|
|
.arg(Arg::with_name("WORKING-DIRECTORY")
|
2017-09-10 22:56:17 -07:00
|
|
|
.short("d")
|
2017-04-20 22:49:51 -07:00
|
|
|
.long("working-directory")
|
|
|
|
.takes_value(true)
|
2017-11-17 23:59:36 -08:00
|
|
|
.help("Use <WORKING-DIRECTORY> as working directory. --justfile must also be set")
|
2017-04-20 23:24:23 -07:00
|
|
|
.requires("JUSTFILE"))
|
|
|
|
.group(ArgGroup::with_name("EARLY-EXIT")
|
|
|
|
.args(&["DUMP", "EDIT", "LIST", "SHOW", "SUMMARY", "ARGUMENTS", "EVALUATE"]))
|
2016-10-23 16:43:52 -07:00
|
|
|
.get_matches();
|
|
|
|
|
2017-06-01 18:01:35 -07:00
|
|
|
let color = match matches.value_of("COLOR").expect("`--color` had no value") {
|
|
|
|
"auto" => Color::auto(),
|
|
|
|
"always" => Color::always(),
|
|
|
|
"never" => Color::never(),
|
|
|
|
other => die!("Invalid argument `{}` to --color. This is a bug in just.", other),
|
2016-11-15 20:39:56 -08:00
|
|
|
};
|
2016-11-07 21:01:27 -08:00
|
|
|
|
2018-02-16 00:52:00 -08:00
|
|
|
if color.active() {
|
|
|
|
#[cfg(windows)]
|
|
|
|
enable_ansi_support().ok();
|
|
|
|
}
|
|
|
|
|
2017-04-20 23:24:23 -07:00
|
|
|
let set_count = matches.occurrences_of("SET");
|
2017-11-16 23:30:08 -08:00
|
|
|
let mut overrides = Map::new();
|
2016-12-30 00:09:35 -08:00
|
|
|
if set_count > 0 {
|
2017-04-20 23:24:23 -07:00
|
|
|
let mut values = matches.values_of("SET").unwrap();
|
2016-12-30 00:09:35 -08:00
|
|
|
for _ in 0..set_count {
|
|
|
|
overrides.insert(values.next().unwrap(), values.next().unwrap());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-21 22:20:13 -07:00
|
|
|
let override_re = Regex::new("^([^=]+)=(.*)$").unwrap();
|
2016-12-30 00:09:35 -08:00
|
|
|
|
2017-04-20 23:24:23 -07:00
|
|
|
let raw_arguments = matches.values_of("ARGUMENTS").map(|values| values.collect::<Vec<_>>())
|
2016-12-30 00:09:35 -08:00
|
|
|
.unwrap_or_default();
|
|
|
|
|
|
|
|
for argument in raw_arguments.iter().take_while(|arg| override_re.is_match(arg)) {
|
|
|
|
let captures = override_re.captures(argument).unwrap();
|
2017-09-10 17:28:00 -07:00
|
|
|
overrides.insert(captures.get(1).unwrap().as_str(), captures.get(2).unwrap().as_str());
|
2016-12-30 00:09:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
let rest = raw_arguments.iter().skip_while(|arg| override_re.is_match(arg))
|
|
|
|
.enumerate()
|
|
|
|
.flat_map(|(i, argument)| {
|
|
|
|
if i == 0 {
|
2016-12-30 00:23:32 -08:00
|
|
|
if let Some(i) = argument.rfind('/') {
|
2017-04-20 23:24:23 -07:00
|
|
|
if matches.is_present("WORKING-DIRECTORY") {
|
2016-12-30 00:09:35 -08:00
|
|
|
die!("--working-directory and a path prefixed recipe may not be used together.");
|
|
|
|
}
|
|
|
|
|
|
|
|
let (dir, recipe) = argument.split_at(i + 1);
|
|
|
|
|
|
|
|
if let Err(error) = env::set_current_dir(dir) {
|
|
|
|
die!("Error changing directory: {}", error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if recipe.is_empty() {
|
|
|
|
return None;
|
|
|
|
} else {
|
|
|
|
return Some(recipe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Some(*argument)
|
|
|
|
})
|
|
|
|
.collect::<Vec<&str>>();
|
|
|
|
|
2017-04-20 23:24:23 -07:00
|
|
|
let justfile_option = matches.value_of("JUSTFILE");
|
|
|
|
let working_directory_option = matches.value_of("WORKING-DIRECTORY");
|
2016-10-23 19:56:30 -07:00
|
|
|
|
|
|
|
let text;
|
|
|
|
if let (Some(file), Some(directory)) = (justfile_option, working_directory_option) {
|
2017-04-20 23:24:23 -07:00
|
|
|
if matches.is_present("EDIT") {
|
2016-11-12 14:02:15 -08:00
|
|
|
edit(file);
|
|
|
|
}
|
|
|
|
|
2016-10-23 19:56:30 -07:00
|
|
|
text = fs::File::open(file)
|
|
|
|
.unwrap_or_else(|error| die!("Error opening justfile: {}", error))
|
|
|
|
.slurp()
|
|
|
|
.unwrap_or_else(|error| die!("Error reading justfile: {}", error));
|
|
|
|
|
|
|
|
if let Err(error) = env::set_current_dir(directory) {
|
|
|
|
die!("Error changing directory to {}: {}", directory, error);
|
|
|
|
}
|
|
|
|
} else {
|
2016-11-05 01:25:36 -07:00
|
|
|
let name;
|
|
|
|
'outer: loop {
|
|
|
|
for candidate in &["justfile", "Justfile"] {
|
|
|
|
match fs::metadata(candidate) {
|
|
|
|
Ok(metadata) => if metadata.is_file() {
|
|
|
|
name = *candidate;
|
|
|
|
break 'outer;
|
|
|
|
},
|
|
|
|
Err(error) => {
|
|
|
|
if error.kind() != io::ErrorKind::NotFound {
|
|
|
|
die!("Error fetching justfile metadata: {}", error)
|
|
|
|
}
|
2016-10-23 19:56:30 -07:00
|
|
|
}
|
2016-10-23 16:43:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-23 19:56:30 -07:00
|
|
|
match env::current_dir() {
|
|
|
|
Ok(pathbuf) => if pathbuf.as_os_str() == "/" { die!("No justfile found."); },
|
|
|
|
Err(error) => die!("Error getting current dir: {}", error),
|
|
|
|
}
|
2016-10-23 16:43:52 -07:00
|
|
|
|
2016-10-23 19:56:30 -07:00
|
|
|
if let Err(error) = env::set_current_dir("..") {
|
|
|
|
die!("Error changing directory: {}", error);
|
|
|
|
}
|
2016-10-23 16:43:52 -07:00
|
|
|
}
|
|
|
|
|
2017-04-20 23:24:23 -07:00
|
|
|
if matches.is_present("EDIT") {
|
2016-11-12 14:02:15 -08:00
|
|
|
edit(name);
|
|
|
|
}
|
|
|
|
|
2016-11-05 01:25:36 -07:00
|
|
|
text = fs::File::open(name)
|
2016-10-23 19:56:30 -07:00
|
|
|
.unwrap_or_else(|error| die!("Error opening justfile: {}", error))
|
|
|
|
.slurp()
|
|
|
|
.unwrap_or_else(|error| die!("Error reading justfile: {}", error));
|
|
|
|
}
|
2016-10-23 16:43:52 -07:00
|
|
|
|
2017-11-18 03:36:02 -08:00
|
|
|
let justfile = Parser::parse(&text).unwrap_or_else(|error|
|
2017-06-01 18:01:35 -07:00
|
|
|
if color.stderr().active() {
|
2016-11-07 21:01:27 -08:00
|
|
|
die!("{:#}", error);
|
|
|
|
} else {
|
|
|
|
die!("{}", error);
|
|
|
|
}
|
|
|
|
);
|
2016-10-23 16:43:52 -07:00
|
|
|
|
2017-04-20 23:24:23 -07:00
|
|
|
if matches.is_present("SUMMARY") {
|
2016-10-23 16:43:52 -07:00
|
|
|
if justfile.count() == 0 {
|
2017-08-18 14:15:43 -07:00
|
|
|
eprintln!("Justfile contains no recipes.");
|
2016-10-23 16:43:52 -07:00
|
|
|
} else {
|
2017-10-06 23:48:07 -07:00
|
|
|
let summary = justfile.recipes.iter()
|
|
|
|
.filter(|&(_, recipe)| !recipe.private)
|
|
|
|
.map(|(name, _)| name)
|
|
|
|
.cloned()
|
|
|
|
.collect::<Vec<_>>()
|
|
|
|
.join(" ");
|
|
|
|
println!("{}", summary);
|
2016-10-23 16:43:52 -07:00
|
|
|
}
|
2017-04-21 22:11:18 -07:00
|
|
|
process::exit(EXIT_SUCCESS);
|
2016-10-23 16:43:52 -07:00
|
|
|
}
|
|
|
|
|
2017-04-20 23:24:23 -07:00
|
|
|
if matches.is_present("DUMP") {
|
2016-11-11 20:25:37 -08:00
|
|
|
println!("{}", justfile);
|
2017-04-21 22:11:18 -07:00
|
|
|
process::exit(EXIT_SUCCESS);
|
2016-11-11 20:25:37 -08:00
|
|
|
}
|
|
|
|
|
2017-04-20 23:24:23 -07:00
|
|
|
if matches.is_present("LIST") {
|
2017-11-30 15:03:59 -08:00
|
|
|
let mut line_widths: Map<&str, usize> = Map::new();
|
|
|
|
|
|
|
|
for (name, recipe) in &justfile.recipes {
|
|
|
|
if recipe.private {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut line_width = UnicodeWidthStr::width(*name);
|
|
|
|
|
|
|
|
for parameter in &recipe.parameters {
|
|
|
|
line_width += UnicodeWidthStr::width(format!(" {}", parameter).as_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
if line_width <= 30 {
|
|
|
|
line_widths.insert(name, line_width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let max_line_width = cmp::min(line_widths.values().cloned().max().unwrap_or(0), 30);
|
|
|
|
|
2017-06-01 18:01:35 -07:00
|
|
|
let doc_color = color.stdout().doc();
|
2016-11-12 11:40:52 -08:00
|
|
|
println!("Available recipes:");
|
|
|
|
for (name, recipe) in &justfile.recipes {
|
2017-10-06 23:48:07 -07:00
|
|
|
if recipe.private {
|
|
|
|
continue;
|
|
|
|
}
|
2016-11-12 11:40:52 -08:00
|
|
|
print!(" {}", name);
|
|
|
|
for parameter in &recipe.parameters {
|
2017-06-01 18:01:35 -07:00
|
|
|
if color.stdout().active() {
|
2016-11-12 23:31:19 -08:00
|
|
|
print!(" {:#}", parameter);
|
|
|
|
} else {
|
|
|
|
print!(" {}", parameter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if let Some(doc) = recipe.doc {
|
2017-11-30 15:03:59 -08:00
|
|
|
print!(
|
|
|
|
" {:padding$}{} {}", "", doc_color.paint("#"), doc_color.paint(doc),
|
2017-12-11 12:44:45 -08:00
|
|
|
padding = max_line_width.saturating_sub(
|
|
|
|
line_widths.get(name).cloned().unwrap_or(max_line_width)
|
|
|
|
)
|
2017-11-30 15:03:59 -08:00
|
|
|
);
|
2016-11-12 11:40:52 -08:00
|
|
|
}
|
2017-11-17 17:28:06 -08:00
|
|
|
println!();
|
2016-11-12 11:40:52 -08:00
|
|
|
}
|
2017-04-21 22:11:18 -07:00
|
|
|
process::exit(EXIT_SUCCESS);
|
2016-11-12 11:40:52 -08:00
|
|
|
}
|
|
|
|
|
2017-04-20 23:24:23 -07:00
|
|
|
if let Some(name) = matches.value_of("SHOW") {
|
2016-11-12 11:40:52 -08:00
|
|
|
match justfile.recipes.get(name) {
|
2016-10-23 16:43:52 -07:00
|
|
|
Some(recipe) => {
|
2016-10-28 16:32:13 -07:00
|
|
|
println!("{}", recipe);
|
2017-04-21 22:11:18 -07:00
|
|
|
process::exit(EXIT_SUCCESS);
|
2016-10-23 16:43:52 -07:00
|
|
|
}
|
2016-11-12 12:36:12 -08:00
|
|
|
None => {
|
2017-08-18 14:15:43 -07:00
|
|
|
eprintln!("Justfile does not contain recipe `{}`.", name);
|
2016-11-12 12:36:12 -08:00
|
|
|
if let Some(suggestion) = justfile.suggest(name) {
|
2017-08-18 14:15:43 -07:00
|
|
|
eprintln!("Did you mean `{}`?", suggestion);
|
2016-11-12 12:36:12 -08:00
|
|
|
}
|
2017-04-21 22:11:18 -07:00
|
|
|
process::exit(EXIT_FAILURE)
|
2016-11-12 12:36:12 -08:00
|
|
|
}
|
2016-10-23 16:43:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-13 21:26:28 -08:00
|
|
|
let arguments = if !rest.is_empty() {
|
2016-10-30 03:08:28 -07:00
|
|
|
rest
|
2016-10-29 00:14:41 -07:00
|
|
|
} else if let Some(recipe) = justfile.first() {
|
2017-05-07 15:11:10 -07:00
|
|
|
let min_arguments = recipe.min_arguments();
|
|
|
|
if min_arguments > 0 {
|
|
|
|
die!("Recipe `{}` cannot be used as default recipe since it requires at least {} argument{}.",
|
|
|
|
recipe.name, min_arguments, maybe_s(min_arguments));
|
|
|
|
}
|
|
|
|
vec![recipe.name]
|
2016-10-23 16:43:52 -07:00
|
|
|
} else {
|
2017-05-07 14:50:46 -07:00
|
|
|
die!("Justfile contains no recipes.");
|
2016-10-23 16:43:52 -07:00
|
|
|
};
|
|
|
|
|
2017-11-17 23:23:02 -08:00
|
|
|
let configuration = Configuration {
|
2017-04-20 23:24:23 -07:00
|
|
|
dry_run: matches.is_present("DRY-RUN"),
|
|
|
|
evaluate: matches.is_present("EVALUATE"),
|
2017-04-25 23:39:34 -07:00
|
|
|
highlight: matches.is_present("HIGHLIGHT"),
|
2017-04-20 23:24:23 -07:00
|
|
|
quiet: matches.is_present("QUIET"),
|
2017-11-16 23:30:08 -08:00
|
|
|
shell: matches.value_of("SHELL").unwrap(),
|
2017-04-20 23:24:23 -07:00
|
|
|
verbose: matches.is_present("VERBOSE"),
|
2018-03-05 13:21:35 -08:00
|
|
|
color,
|
|
|
|
overrides,
|
2016-11-05 00:31:38 -07:00
|
|
|
};
|
2016-10-30 13:14:39 -07:00
|
|
|
|
2017-11-17 23:23:02 -08:00
|
|
|
if let Err(run_error) = justfile.run(&arguments, &configuration) {
|
|
|
|
if !configuration.quiet {
|
2017-06-01 18:01:35 -07:00
|
|
|
if color.stderr().active() {
|
2017-08-18 14:15:43 -07:00
|
|
|
eprintln!("{:#}", run_error);
|
2016-11-07 21:01:27 -08:00
|
|
|
} else {
|
2017-08-18 14:15:43 -07:00
|
|
|
eprintln!("{}", run_error);
|
2016-11-07 21:01:27 -08:00
|
|
|
}
|
2016-11-05 01:01:43 -07:00
|
|
|
}
|
2017-04-23 14:21:21 -07:00
|
|
|
|
2017-11-16 23:30:08 -08:00
|
|
|
process::exit(run_error.code().unwrap_or(EXIT_FAILURE));
|
2016-10-23 16:43:52 -07:00
|
|
|
}
|
|
|
|
}
|