2019-10-09 01:40:40 -07:00
|
|
|
use crate::common::*;
|
2019-06-01 22:38:03 -07: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
|
|
|
#[derive(Debug, Snafu)]
|
|
|
|
#[snafu(visibility(pub(crate)))]
|
2019-09-21 15:35:03 -07:00
|
|
|
pub(crate) enum SearchError {
|
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
|
|
|
#[snafu(display(
|
|
|
|
"Multiple candidate justfiles found in `{}`: {}",
|
|
|
|
candidates[0].parent().unwrap().display(),
|
|
|
|
List::and_ticked(
|
|
|
|
candidates
|
|
|
|
.iter()
|
|
|
|
.map(|candidate| candidate.file_name().unwrap().to_string_lossy())
|
|
|
|
),
|
|
|
|
))]
|
2019-11-19 03:51:44 -08:00
|
|
|
MultipleCandidates { candidates: Vec<PathBuf> },
|
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
|
|
|
#[snafu(display(
|
|
|
|
"I/O error reading directory `{}`: {}",
|
|
|
|
directory.display(),
|
|
|
|
io_error
|
|
|
|
))]
|
2019-06-01 22:38:03 -07:00
|
|
|
Io {
|
|
|
|
directory: PathBuf,
|
2020-02-10 20:07:06 -08:00
|
|
|
io_error: io::Error,
|
2019-06-01 22:38:03 -07: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
|
|
|
#[snafu(display("No justfile found"))]
|
2019-06-01 22:38:03 -07:00
|
|
|
NotFound,
|
2019-11-19 03:51:44 -08:00
|
|
|
#[snafu(display("Justfile path had no parent: {}", path.display()))]
|
|
|
|
JustfileHadNoParent { path: PathBuf },
|
2019-06-01 22:38:03 -07: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 SearchError {}
|
2019-06-01 22:38:03 -07:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn multiple_candidates_formatting() {
|
|
|
|
let error = SearchError::MultipleCandidates {
|
|
|
|
candidates: vec![
|
|
|
|
PathBuf::from("/foo/justfile"),
|
|
|
|
PathBuf::from("/foo/JUSTFILE"),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
error.to_string(),
|
|
|
|
"Multiple candidate justfiles found in `/foo`: `justfile` and `JUSTFILE`"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|