diff options
author | Benjamin Nguyen <benjamin.van.nguyen@gmail.com> | 2023-07-01 11:25:49 +0700 |
---|---|---|
committer | Benjamin Nguyen <benjamin.van.nguyen@gmail.com> | 2023-07-01 11:25:49 +0700 |
commit | 7c191548ec669e08f74b3eaf0f9887ce18b9394d (patch) | |
tree | 4175e8e9b0f0fb10515d8f25614a3f0d88f024d8 | |
parent | 74f865d0665e04ae6353aee7171d079ae7aa1db1 (diff) |
version bump and err messages
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/context/args.rs | 14 | ||||
-rw-r--r-- | src/context/error.rs | 6 | ||||
-rw-r--r-- | src/context/mod.rs | 2 |
5 files changed, 21 insertions, 5 deletions
@@ -344,7 +344,7 @@ checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" [[package]] name = "erdtree" -version = "3.0.2" +version = "3.1.0" dependencies = [ "ansi_term", "chrono", @@ -1,6 +1,6 @@ [package] name = "erdtree" -version = "3.0.2" +version = "3.1.0" edition = "2021" authors = ["Benjamin Nguyen <benjamin.van.nguyen@gmail.com>"] description = """ diff --git a/src/context/args.rs b/src/context/args.rs index bc4ea68..17027cc 100644 --- a/src/context/args.rs +++ b/src/context/args.rs @@ -27,12 +27,22 @@ pub trait Reconciler: CommandFactory + FromArgMatches { } let maybe_config_args = { + let named_table = user_args.get_one::<String>("config"); + if let Some(rc) = load_rc_config_args() { + if named_table.is_some() { + return Err(Error::Rc); + } + Some(rc) } else { - let named_table = user_args.get_one::<String>("config"); + let toml = load_toml_config_args(named_table.map(String::as_str))?; + + if named_table.is_some() && toml.is_none() { + return Err(Error::NoToml); + } - load_toml_config_args(named_table.map(String::as_str))? + toml } }; diff --git a/src/context/error.rs b/src/context/error.rs index 3726b83..6b2e82b 100644 --- a/src/context/error.rs +++ b/src/context/error.rs @@ -29,6 +29,12 @@ pub enum Error { #[error("{0}")] MatchError(#[from] MatchesError), + + #[error("'--config' was specified but a `.erdtree.toml` file could not be found")] + NoToml, + + #[error("Please migrate from `erdtreerc` to `.erdtree.toml` to make use of `--config`")] + Rc, } impl From<TomlError> for Error { diff --git a/src/context/mod.rs b/src/context/mod.rs index 03fdd2f..829b9ca 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -53,7 +53,7 @@ pub mod time; #[derive(Parser, Debug)] #[command(name = "erdtree")] #[command(author = "Benjamin Nguyen. <benjamin.van.nguyen@gmail.com>")] -#[command(version = "3.0.2")] +#[command(version = "3.1.0")] #[command(about = "erdtree (erd) is a cross-platform, multi-threaded, and general purpose filesystem and disk usage utility.", long_about = None)] pub struct Context { /// Directory to traverse; defaults to current working directory |