2018-08-31 00:04:06 -07:00
|
|
|
use Verbosity::*;
|
|
|
|
|
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(Copy, Clone, Debug, PartialEq)]
|
2019-09-21 15:35:03 -07:00
|
|
|
pub(crate) enum Verbosity {
|
2020-10-01 20:00:15 -07:00
|
|
|
Quiet,
|
2018-08-31 00:04:06 -07:00
|
|
|
Taciturn,
|
|
|
|
Loquacious,
|
|
|
|
Grandiloquent,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Verbosity {
|
2024-05-14 20:29:40 -07:00
|
|
|
pub(crate) fn from_flag_occurrences(flag_occurrences: u8) -> Self {
|
2022-05-28 19:07:53 -07:00
|
|
|
match flag_occurrences {
|
2018-08-31 00:04:06 -07:00
|
|
|
0 => Taciturn,
|
|
|
|
1 => Loquacious,
|
|
|
|
_ => Grandiloquent,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 20:00:15 -07:00
|
|
|
pub(crate) fn quiet(self) -> bool {
|
2020-10-09 15:44:17 -07:00
|
|
|
matches!(self, Quiet)
|
2020-10-01 20:00:15 -07:00
|
|
|
}
|
|
|
|
|
2021-03-25 16:51:29 -07:00
|
|
|
pub(crate) fn loud(self) -> bool {
|
|
|
|
!self.quiet()
|
|
|
|
}
|
|
|
|
|
2019-09-21 15:35:03 -07:00
|
|
|
pub(crate) fn loquacious(self) -> bool {
|
2018-08-31 00:04:06 -07:00
|
|
|
match self {
|
2020-10-01 20:00:15 -07:00
|
|
|
Quiet | Taciturn => false,
|
2020-01-15 02:16:13 -08:00
|
|
|
Loquacious | Grandiloquent => true,
|
2018-08-31 00:04:06 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-21 15:35:03 -07:00
|
|
|
pub(crate) fn grandiloquent(self) -> bool {
|
2018-08-31 00:04:06 -07:00
|
|
|
match self {
|
2020-10-01 20:00:15 -07:00
|
|
|
Quiet | Taciturn | Loquacious => false,
|
2018-08-31 00:04:06 -07:00
|
|
|
Grandiloquent => true,
|
|
|
|
}
|
|
|
|
}
|
2021-03-25 16:51:29 -07:00
|
|
|
|
2022-12-15 16:53:21 -08:00
|
|
|
pub const fn default() -> Self {
|
2023-10-16 20:07:09 -07:00
|
|
|
Taciturn
|
2021-03-25 16:51:29 -07:00
|
|
|
}
|
|
|
|
}
|