2019-04-11 15:23:14 -07:00
|
|
|
use crate::common::*;
|
2018-03-05 13:21:35 -08:00
|
|
|
|
2017-11-16 23:30:08 -08:00
|
|
|
#[derive(Debug)]
|
2019-09-21 15:35:03 -07:00
|
|
|
pub(crate) enum RuntimeError<'a> {
|
2018-12-08 14:29:41 -08:00
|
|
|
ArgumentCountMismatch {
|
2018-11-06 00:41:33 -08:00
|
|
|
recipe: &'a str,
|
|
|
|
parameters: Vec<&'a Parameter<'a>>,
|
|
|
|
found: usize,
|
|
|
|
min: usize,
|
|
|
|
max: usize,
|
|
|
|
},
|
2018-12-08 14:29:41 -08:00
|
|
|
Backtick {
|
|
|
|
token: Token<'a>,
|
|
|
|
output_error: OutputError,
|
|
|
|
},
|
|
|
|
Code {
|
|
|
|
recipe: &'a str,
|
|
|
|
line_number: Option<usize>,
|
|
|
|
code: i32,
|
|
|
|
},
|
|
|
|
Cygpath {
|
|
|
|
recipe: &'a str,
|
|
|
|
output_error: OutputError,
|
|
|
|
},
|
|
|
|
Dotenv {
|
|
|
|
dotenv_error: dotenv::Error,
|
|
|
|
},
|
|
|
|
FunctionCall {
|
2019-11-07 10:55:15 -08:00
|
|
|
function: Name<'a>,
|
2018-12-08 14:29:41 -08:00
|
|
|
message: String,
|
|
|
|
},
|
|
|
|
Internal {
|
|
|
|
message: String,
|
|
|
|
},
|
|
|
|
IoError {
|
|
|
|
recipe: &'a str,
|
|
|
|
io_error: io::Error,
|
|
|
|
},
|
|
|
|
Shebang {
|
|
|
|
recipe: &'a str,
|
|
|
|
command: String,
|
|
|
|
argument: Option<String>,
|
|
|
|
io_error: io::Error,
|
|
|
|
},
|
|
|
|
Signal {
|
|
|
|
recipe: &'a str,
|
|
|
|
line_number: Option<usize>,
|
|
|
|
signal: i32,
|
|
|
|
},
|
|
|
|
TmpdirIoError {
|
|
|
|
recipe: &'a str,
|
|
|
|
io_error: io::Error,
|
|
|
|
},
|
|
|
|
UnknownOverrides {
|
|
|
|
overrides: Vec<&'a str>,
|
|
|
|
},
|
|
|
|
UnknownRecipes {
|
|
|
|
recipes: Vec<&'a str>,
|
|
|
|
suggestion: Option<&'a str>,
|
|
|
|
},
|
|
|
|
Unknown {
|
|
|
|
recipe: &'a str,
|
|
|
|
line_number: Option<usize>,
|
|
|
|
},
|
Gargantuan refactor (#522)
- Instead of changing the current directory with `env::set_current_dir`
to be implicitly inherited by subprocesses, we now use
`Command::current_dir` to set it explicitly. This feels much better,
since we aren't dependent on the implicit state of the process's
current directory.
- Subcommand execution is much improved.
- Added a ton of tests for config parsing, config execution, working
dir, and search dir.
- Error messages are improved. Many more will be colored.
- The Config is now onwed, instead of borrowing from the arguments and
the `clap::ArgMatches` object. This is a huge ergonomic improvement,
especially in tests, and I don't think anyone will notice.
- `--edit` now uses `$VISUAL`, `$EDITOR`, or `vim`, in that order,
matching git, which I think is what most people will expect.
- Added a cute `tmptree!{}` macro, for creating temporary directories
populated with directories and files for tests.
- Admitted that grammer is LL(k) and I don't know what `k` is.
2019-11-09 21:43:20 -08:00
|
|
|
NoRecipes,
|
|
|
|
DefaultRecipeRequiresArguments {
|
|
|
|
recipe: &'a str,
|
|
|
|
min_arguments: usize,
|
|
|
|
},
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
|
Gargantuan refactor (#522)
- Instead of changing the current directory with `env::set_current_dir`
to be implicitly inherited by subprocesses, we now use
`Command::current_dir` to set it explicitly. This feels much better,
since we aren't dependent on the implicit state of the process's
current directory.
- Subcommand execution is much improved.
- Added a ton of tests for config parsing, config execution, working
dir, and search dir.
- Error messages are improved. Many more will be colored.
- The Config is now onwed, instead of borrowing from the arguments and
the `clap::ArgMatches` object. This is a huge ergonomic improvement,
especially in tests, and I don't think anyone will notice.
- `--edit` now uses `$VISUAL`, `$EDITOR`, or `vim`, in that order,
matching git, which I think is what most people will expect.
- Added a cute `tmptree!{}` macro, for creating temporary directories
populated with directories and files for tests.
- Admitted that grammer is LL(k) and I don't know what `k` is.
2019-11-09 21:43:20 -08:00
|
|
|
impl Error for RuntimeError<'_> {
|
|
|
|
fn code(&self) -> i32 {
|
2017-11-16 23:30:08 -08:00
|
|
|
match *self {
|
Gargantuan refactor (#522)
- Instead of changing the current directory with `env::set_current_dir`
to be implicitly inherited by subprocesses, we now use
`Command::current_dir` to set it explicitly. This feels much better,
since we aren't dependent on the implicit state of the process's
current directory.
- Subcommand execution is much improved.
- Added a ton of tests for config parsing, config execution, working
dir, and search dir.
- Error messages are improved. Many more will be colored.
- The Config is now onwed, instead of borrowing from the arguments and
the `clap::ArgMatches` object. This is a huge ergonomic improvement,
especially in tests, and I don't think anyone will notice.
- `--edit` now uses `$VISUAL`, `$EDITOR`, or `vim`, in that order,
matching git, which I think is what most people will expect.
- Added a cute `tmptree!{}` macro, for creating temporary directories
populated with directories and files for tests.
- Admitted that grammer is LL(k) and I don't know what `k` is.
2019-11-09 21:43:20 -08:00
|
|
|
Self::Code { code, .. } => code,
|
|
|
|
Self::Backtick {
|
2018-12-08 14:29:41 -08:00
|
|
|
output_error: OutputError::Code(code),
|
|
|
|
..
|
Gargantuan refactor (#522)
- Instead of changing the current directory with `env::set_current_dir`
to be implicitly inherited by subprocesses, we now use
`Command::current_dir` to set it explicitly. This feels much better,
since we aren't dependent on the implicit state of the process's
current directory.
- Subcommand execution is much improved.
- Added a ton of tests for config parsing, config execution, working
dir, and search dir.
- Error messages are improved. Many more will be colored.
- The Config is now onwed, instead of borrowing from the arguments and
the `clap::ArgMatches` object. This is a huge ergonomic improvement,
especially in tests, and I don't think anyone will notice.
- `--edit` now uses `$VISUAL`, `$EDITOR`, or `vim`, in that order,
matching git, which I think is what most people will expect.
- Added a cute `tmptree!{}` macro, for creating temporary directories
populated with directories and files for tests.
- Admitted that grammer is LL(k) and I don't know what `k` is.
2019-11-09 21:43:20 -08:00
|
|
|
} => code,
|
|
|
|
_ => EXIT_FAILURE,
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Display for RuntimeError<'a> {
|
2019-04-11 15:23:14 -07:00
|
|
|
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
|
2017-11-16 23:30:08 -08:00
|
|
|
use RuntimeError::*;
|
2019-04-11 15:23:14 -07:00
|
|
|
|
2018-12-08 14:29:41 -08:00
|
|
|
let color = if f.alternate() {
|
|
|
|
Color::always()
|
|
|
|
} else {
|
|
|
|
Color::never()
|
|
|
|
};
|
2017-11-16 23:30:08 -08:00
|
|
|
let message = color.message();
|
Gargantuan refactor (#522)
- Instead of changing the current directory with `env::set_current_dir`
to be implicitly inherited by subprocesses, we now use
`Command::current_dir` to set it explicitly. This feels much better,
since we aren't dependent on the implicit state of the process's
current directory.
- Subcommand execution is much improved.
- Added a ton of tests for config parsing, config execution, working
dir, and search dir.
- Error messages are improved. Many more will be colored.
- The Config is now onwed, instead of borrowing from the arguments and
the `clap::ArgMatches` object. This is a huge ergonomic improvement,
especially in tests, and I don't think anyone will notice.
- `--edit` now uses `$VISUAL`, `$EDITOR`, or `vim`, in that order,
matching git, which I think is what most people will expect.
- Added a cute `tmptree!{}` macro, for creating temporary directories
populated with directories and files for tests.
- Admitted that grammer is LL(k) and I don't know what `k` is.
2019-11-09 21:43:20 -08:00
|
|
|
write!(f, "{}", message.prefix())?;
|
2017-11-16 23:30:08 -08:00
|
|
|
|
2019-11-07 10:55:15 -08:00
|
|
|
let mut error_token: Option<Token> = None;
|
2017-11-16 23:30:08 -08:00
|
|
|
|
|
|
|
match *self {
|
2018-12-08 14:29:41 -08:00
|
|
|
UnknownRecipes {
|
|
|
|
ref recipes,
|
|
|
|
ref suggestion,
|
|
|
|
} => {
|
|
|
|
write!(
|
|
|
|
f,
|
2019-10-09 01:40:40 -07:00
|
|
|
"Justfile does not contain {} {}.",
|
|
|
|
Count("recipe", recipes.len()),
|
|
|
|
List::or_ticked(recipes),
|
2018-12-08 14:29:41 -08:00
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
if let Some(suggestion) = *suggestion {
|
|
|
|
write!(f, "\nDid you mean `{}`?", suggestion)?;
|
|
|
|
}
|
2018-12-08 14:29:41 -08:00
|
|
|
}
|
|
|
|
UnknownOverrides { ref overrides } => {
|
|
|
|
write!(
|
|
|
|
f,
|
2019-10-09 01:40:40 -07:00
|
|
|
"{} {} overridden on the command line but not present in justfile",
|
|
|
|
Count("Variable", overrides.len()),
|
|
|
|
List::and_ticked(overrides),
|
2018-12-08 14:29:41 -08:00
|
|
|
)?;
|
|
|
|
}
|
|
|
|
ArgumentCountMismatch {
|
|
|
|
recipe,
|
|
|
|
ref parameters,
|
|
|
|
found,
|
|
|
|
min,
|
|
|
|
max,
|
|
|
|
} => {
|
2017-11-16 23:30:08 -08:00
|
|
|
if min == max {
|
|
|
|
let expected = min;
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
2019-10-09 01:40:40 -07:00
|
|
|
"Recipe `{}` got {} {} but {}takes {}",
|
2018-12-08 14:29:41 -08:00
|
|
|
recipe,
|
|
|
|
found,
|
2019-10-09 01:40:40 -07:00
|
|
|
Count("argument", found),
|
2018-12-08 14:29:41 -08:00
|
|
|
if expected < found { "only " } else { "" },
|
|
|
|
expected
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
} else if found < min {
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
2019-10-09 01:40:40 -07:00
|
|
|
"Recipe `{}` got {} {} but takes at least {}",
|
2018-12-08 14:29:41 -08:00
|
|
|
recipe,
|
|
|
|
found,
|
2019-10-09 01:40:40 -07:00
|
|
|
Count("argument", found),
|
2018-12-08 14:29:41 -08:00
|
|
|
min
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
} else if found > max {
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
2019-10-09 01:40:40 -07:00
|
|
|
"Recipe `{}` got {} {} but takes at most {}",
|
2018-12-08 14:29:41 -08:00
|
|
|
recipe,
|
|
|
|
found,
|
2019-10-09 01:40:40 -07:00
|
|
|
Count("argument", found),
|
2018-12-08 14:29:41 -08:00
|
|
|
max
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
2018-11-03 14:51:06 -07:00
|
|
|
write!(f, "\nusage:\n just {}", recipe)?;
|
|
|
|
for param in parameters {
|
|
|
|
if color.stderr().active() {
|
|
|
|
write!(f, " {:#}", param)?;
|
|
|
|
} else {
|
|
|
|
write!(f, " {}", param)?;
|
|
|
|
}
|
|
|
|
}
|
2018-12-08 14:29:41 -08:00
|
|
|
}
|
|
|
|
Code {
|
|
|
|
recipe,
|
|
|
|
line_number,
|
|
|
|
code,
|
|
|
|
} => {
|
2017-11-16 23:30:08 -08:00
|
|
|
if let Some(n) = line_number {
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"Recipe `{}` failed on line {} with exit code {}",
|
|
|
|
recipe, n, code
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
} else {
|
|
|
|
write!(f, "Recipe `{}` failed with exit code {}", recipe, code)?;
|
|
|
|
}
|
2018-12-08 14:29:41 -08:00
|
|
|
}
|
|
|
|
Cygpath {
|
|
|
|
recipe,
|
|
|
|
ref output_error,
|
|
|
|
} => match *output_error {
|
2017-11-16 23:30:08 -08:00
|
|
|
OutputError::Code(code) => {
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"Cygpath failed with exit code {} while translating recipe `{}` \
|
|
|
|
shebang interpreter path",
|
|
|
|
code, recipe
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
OutputError::Signal(signal) => {
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"Cygpath terminated by signal {} while translating recipe `{}` \
|
|
|
|
shebang interpreter path",
|
|
|
|
signal, recipe
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
OutputError::Unknown => {
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"Cygpath experienced an unknown failure while translating recipe `{}` \
|
|
|
|
shebang interpreter path",
|
|
|
|
recipe
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
OutputError::Io(ref io_error) => {
|
|
|
|
match io_error.kind() {
|
|
|
|
io::ErrorKind::NotFound => write!(
|
2018-12-08 14:29:41 -08:00
|
|
|
f,
|
|
|
|
"Could not find `cygpath` executable to translate recipe `{}` \
|
|
|
|
shebang interpreter path:\n{}",
|
|
|
|
recipe, io_error
|
|
|
|
),
|
2017-11-16 23:30:08 -08:00
|
|
|
io::ErrorKind::PermissionDenied => write!(
|
2018-12-08 14:29:41 -08:00
|
|
|
f,
|
|
|
|
"Could not run `cygpath` executable to translate recipe `{}` \
|
|
|
|
shebang interpreter path:\n{}",
|
|
|
|
recipe, io_error
|
|
|
|
),
|
2017-11-16 23:30:08 -08:00
|
|
|
_ => write!(f, "Could not run `cygpath` executable:\n{}", io_error),
|
|
|
|
}?;
|
|
|
|
}
|
|
|
|
OutputError::Utf8(ref utf8_error) => {
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"Cygpath successfully translated recipe `{}` shebang interpreter path, \
|
|
|
|
but output was not utf8: {}",
|
|
|
|
recipe, utf8_error
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
},
|
2018-12-08 14:29:41 -08:00
|
|
|
Dotenv { ref dotenv_error } => {
|
2018-08-27 18:36:40 -07:00
|
|
|
writeln!(f, "Failed to load .env: {}", dotenv_error)?;
|
2018-03-05 13:21:35 -08:00
|
|
|
}
|
2018-12-08 14:29:41 -08:00
|
|
|
FunctionCall {
|
2019-11-07 10:55:15 -08:00
|
|
|
ref function,
|
2018-12-08 14:29:41 -08:00
|
|
|
ref message,
|
|
|
|
} => {
|
2019-04-15 22:40:02 -07:00
|
|
|
writeln!(
|
|
|
|
f,
|
|
|
|
"Call to function `{}` failed: {}",
|
2019-11-07 10:55:15 -08:00
|
|
|
function.lexeme(),
|
2019-04-15 22:40:02 -07:00
|
|
|
message
|
|
|
|
)?;
|
2019-11-07 10:55:15 -08:00
|
|
|
error_token = Some(function.token());
|
2017-12-02 14:59:07 -08:00
|
|
|
}
|
2018-12-08 14:29:41 -08:00
|
|
|
Shebang {
|
|
|
|
recipe,
|
|
|
|
ref command,
|
|
|
|
ref argument,
|
|
|
|
ref io_error,
|
|
|
|
} => {
|
2017-11-16 23:30:08 -08:00
|
|
|
if let Some(ref argument) = *argument {
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"Recipe `{}` with shebang `#!{} {}` execution error: {}",
|
|
|
|
recipe, command, argument, io_error
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
} else {
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"Recipe `{}` with shebang `#!{}` execution error: {}",
|
|
|
|
recipe, command, io_error
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
}
|
2018-12-08 14:29:41 -08:00
|
|
|
Signal {
|
|
|
|
recipe,
|
|
|
|
line_number,
|
|
|
|
signal,
|
|
|
|
} => {
|
2017-11-16 23:30:08 -08:00
|
|
|
if let Some(n) = line_number {
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"Recipe `{}` was terminated on line {} by signal {}",
|
|
|
|
recipe, n, signal
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
} else {
|
|
|
|
write!(f, "Recipe `{}` was terminated by signal {}", recipe, signal)?;
|
|
|
|
}
|
|
|
|
}
|
2018-12-08 14:29:41 -08:00
|
|
|
Unknown {
|
|
|
|
recipe,
|
|
|
|
line_number,
|
|
|
|
} => {
|
2017-11-16 23:30:08 -08:00
|
|
|
if let Some(n) = line_number {
|
2018-12-08 14:29:41 -08:00
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"Recipe `{}` failed on line {} for an unknown reason",
|
|
|
|
recipe, n
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
} else {
|
|
|
|
}
|
2018-12-08 14:29:41 -08:00
|
|
|
}
|
|
|
|
IoError {
|
|
|
|
recipe,
|
|
|
|
ref io_error,
|
|
|
|
} => {
|
2017-11-16 23:30:08 -08:00
|
|
|
match io_error.kind() {
|
2018-12-08 14:29:41 -08:00
|
|
|
io::ErrorKind::NotFound => writeln!(
|
|
|
|
f,
|
2018-08-27 18:36:40 -07:00
|
|
|
"Recipe `{}` could not be run because just could not find `sh`:{}",
|
2018-12-08 14:29:41 -08:00
|
|
|
recipe, io_error
|
|
|
|
),
|
2018-08-27 18:36:40 -07:00
|
|
|
io::ErrorKind::PermissionDenied => writeln!(
|
2018-12-08 14:29:41 -08:00
|
|
|
f,
|
|
|
|
"Recipe `{}` could not be run because just could not run `sh`:{}",
|
|
|
|
recipe, io_error
|
|
|
|
),
|
|
|
|
_ => writeln!(
|
|
|
|
f,
|
|
|
|
"Recipe `{}` could not be run because of an IO error while \
|
|
|
|
launching `sh`:{}",
|
|
|
|
recipe, io_error
|
|
|
|
),
|
2017-11-16 23:30:08 -08:00
|
|
|
}?;
|
2018-12-08 14:29:41 -08:00
|
|
|
}
|
|
|
|
TmpdirIoError {
|
|
|
|
recipe,
|
|
|
|
ref io_error,
|
|
|
|
} => writeln!(
|
|
|
|
f,
|
|
|
|
"Recipe `{}` could not be run because of an IO error while trying \
|
|
|
|
to create a temporary directory or write a file to that directory`:{}",
|
|
|
|
recipe, io_error
|
|
|
|
)?,
|
|
|
|
Backtick {
|
|
|
|
ref token,
|
|
|
|
ref output_error,
|
|
|
|
} => match *output_error {
|
2017-11-16 23:30:08 -08:00
|
|
|
OutputError::Code(code) => {
|
2018-08-27 18:36:40 -07:00
|
|
|
writeln!(f, "Backtick failed with exit code {}", code)?;
|
2019-11-07 10:55:15 -08:00
|
|
|
error_token = Some(*token);
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
OutputError::Signal(signal) => {
|
2018-08-27 18:36:40 -07:00
|
|
|
writeln!(f, "Backtick was terminated by signal {}", signal)?;
|
2019-11-07 10:55:15 -08:00
|
|
|
error_token = Some(*token);
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
OutputError::Unknown => {
|
2018-08-27 18:36:40 -07:00
|
|
|
writeln!(f, "Backtick failed for an unknown reason")?;
|
2019-11-07 10:55:15 -08:00
|
|
|
error_token = Some(*token);
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
OutputError::Io(ref io_error) => {
|
|
|
|
match io_error.kind() {
|
|
|
|
io::ErrorKind::NotFound => write!(
|
2018-12-08 14:29:41 -08:00
|
|
|
f,
|
|
|
|
"Backtick could not be run because just could not find `sh`:\n{}",
|
|
|
|
io_error
|
|
|
|
),
|
2017-11-16 23:30:08 -08:00
|
|
|
io::ErrorKind::PermissionDenied => write!(
|
2018-12-08 14:29:41 -08:00
|
|
|
f,
|
|
|
|
"Backtick could not be run because just could not run `sh`:\n{}",
|
|
|
|
io_error
|
|
|
|
),
|
|
|
|
_ => write!(
|
|
|
|
f,
|
|
|
|
"Backtick could not be run because of an IO \
|
|
|
|
error while launching `sh`:\n{}",
|
|
|
|
io_error
|
|
|
|
),
|
2017-11-16 23:30:08 -08:00
|
|
|
}?;
|
2019-11-07 10:55:15 -08:00
|
|
|
error_token = Some(*token);
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
OutputError::Utf8(ref utf8_error) => {
|
2018-12-08 14:29:41 -08:00
|
|
|
writeln!(
|
|
|
|
f,
|
|
|
|
"Backtick succeeded but stdout was not utf8: {}",
|
|
|
|
utf8_error
|
|
|
|
)?;
|
2019-11-07 10:55:15 -08:00
|
|
|
error_token = Some(*token);
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
},
|
Gargantuan refactor (#522)
- Instead of changing the current directory with `env::set_current_dir`
to be implicitly inherited by subprocesses, we now use
`Command::current_dir` to set it explicitly. This feels much better,
since we aren't dependent on the implicit state of the process's
current directory.
- Subcommand execution is much improved.
- Added a ton of tests for config parsing, config execution, working
dir, and search dir.
- Error messages are improved. Many more will be colored.
- The Config is now onwed, instead of borrowing from the arguments and
the `clap::ArgMatches` object. This is a huge ergonomic improvement,
especially in tests, and I don't think anyone will notice.
- `--edit` now uses `$VISUAL`, `$EDITOR`, or `vim`, in that order,
matching git, which I think is what most people will expect.
- Added a cute `tmptree!{}` macro, for creating temporary directories
populated with directories and files for tests.
- Admitted that grammer is LL(k) and I don't know what `k` is.
2019-11-09 21:43:20 -08:00
|
|
|
NoRecipes => {
|
|
|
|
writeln!(f, "Justfile contains no recipes.",)?;
|
|
|
|
}
|
|
|
|
DefaultRecipeRequiresArguments {
|
|
|
|
recipe,
|
|
|
|
min_arguments,
|
|
|
|
} => {
|
|
|
|
writeln!(
|
|
|
|
f,
|
|
|
|
"Recipe `{}` cannot be used as default recipe since it requires at least {} {}.",
|
|
|
|
recipe,
|
|
|
|
min_arguments,
|
|
|
|
Count("argument", min_arguments),
|
|
|
|
)?;
|
|
|
|
}
|
2018-12-08 14:29:41 -08:00
|
|
|
Internal { ref message } => {
|
|
|
|
write!(
|
|
|
|
f,
|
2019-10-09 00:18:53 -07:00
|
|
|
"Internal runtime error, this may indicate a bug in just: {} \
|
2018-12-08 14:29:41 -08:00
|
|
|
consider filing an issue: https://github.com/casey/just/issues/new",
|
|
|
|
message
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
write!(f, "{}", message.suffix())?;
|
|
|
|
|
|
|
|
if let Some(token) = error_token {
|
2019-09-21 18:53:30 -07:00
|
|
|
write_message_context(
|
2019-04-19 04:07:29 -07:00
|
|
|
f,
|
2019-09-21 18:53:30 -07:00
|
|
|
Color::fmt(f).error(),
|
2019-11-07 10:55:15 -08:00
|
|
|
token.src,
|
2019-04-19 04:07:29 -07:00
|
|
|
token.offset,
|
|
|
|
token.line,
|
|
|
|
token.column,
|
|
|
|
token.lexeme().len(),
|
|
|
|
)?;
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|