Skip to content

Commit

Permalink
add clap requires to flags that depent on --report
Browse files Browse the repository at this point in the history
  • Loading branch information
jhscheer committed Apr 2, 2023
1 parent b473dce commit 6279666
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/render/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ pub struct Context {
pub report: bool,

/// Print human-readable disk usage in report
#[arg(long)]
#[arg(long, requires = "report")]
pub human: bool,

/// Print file-name in report as opposed to full path
#[arg(long)]
#[arg(long, requires = "report")]
pub file_name: bool,

/// Sort-order to display directory content
Expand Down
12 changes: 12 additions & 0 deletions tests/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,15 @@ fn report_with_level() {
)
)
}

#[test]
#[should_panic]
fn report_requires_human() {
utils::run_cmd(&["--human"]);
}

#[test]
#[should_panic]
fn report_requires_file_name() {
utils::run_cmd(&["--file-name"]);
}

0 comments on commit 6279666

Please sign in to comment.