Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
solidiquis committed Oct 10, 2023
1 parent 393baea commit 1b5b2b0
Show file tree
Hide file tree
Showing 87 changed files with 200 additions and 6,664 deletions.
19 changes: 13 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords = ["tree", "find", "ls", "du", "commandline"]
exclude = ["assets/*", "scripts/*", "example/*"]
readme = "README.md"
license = "MIT"
rust-version = "1.70.0"
rust-version = "1.73.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -25,6 +25,7 @@ path = "src/main.rs"

[dependencies]
ansi_term = "0.12.1"
anyhow = "1.0.75"
chrono = "0.4.24"
clap = { version = "4.1.1", features = ["derive"] }
clap_complete = "4.1.1"
Expand Down
9 changes: 0 additions & 9 deletions example/.erdtreerc

This file was deleted.

64 changes: 0 additions & 64 deletions scripts/performance_metrics.sh

This file was deleted.

64 changes: 0 additions & 64 deletions src/ansi.rs

This file was deleted.

41 changes: 41 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use crate::error::{self, ErrorReport, Result, WithContext};
use clap::Parser;
use std::{env, path::PathBuf};

#[derive(Parser, Debug)]
#[command(name = "erdtree")]
#[command(author = "Benjamin Nguyen. <[email protected]>")]
#[command(version = "4.0.0")]
#[command(
about = "erdtree (erd) is a cross-platform, multi-threaded, and general purpose filesystem and disk usage utility.",
long_about = None,
)]
pub struct Args {
/// Directory to traverse; defaults to current working directory
dir: Option<PathBuf>,
}

impl Args {
pub fn init() -> Result<Self> {
let mut clargs = Self::parse();
clargs.set_dir()?;
Ok(clargs)
}

fn set_dir(&mut self) -> Result<()> {
let current_dir = env::current_dir().into_report(error::Category::System)?;

Err(std::io::Error::new(
std::io::ErrorKind::Other,
"This is the underlying error",
))
.into_report(error::Category::User)
.context("Oh my god...")
.context("Look at her butt")
.context("omg..")?;

//.into_report_ctx(error::Category::Internal, "hmmmm")?;

Ok(())
}
}
129 changes: 0 additions & 129 deletions src/context/args.rs

This file was deleted.

Loading

0 comments on commit 1b5b2b0

Please sign in to comment.