Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e32778b

Browse files
committed
1 parent 10aecc0 commit e32778b

4 files changed

Lines changed: 179 additions & 162 deletions

File tree

Cargo.lock

Lines changed: 104 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = "MIT"
1010
include = ["src/**/*", "Cargo.*", "LICENSE", "README.md", "CHANGELOG.md", "!**/*_test/*"]
1111

1212
[dependencies]
13-
argh = "0.1.3"
13+
structopt = "0.3.15"
1414
jwalk = "0.5.0"
1515
byte-unit = "4"
1616
termion = "1.5.2"

src/main.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::interactive::{Interaction, TerminalApp};
44
use anyhow::{Context, Result};
55
use dua::{ByteFormat, Color, TraversalSorting};
66
use std::{fs, io, io::Write, path::PathBuf, process};
7+
use structopt::StructOpt;
78
use termion::{raw::IntoRawMode, screen::AlternateScreen};
89
use tui::backend::TermionBackend;
910
use tui_react::Terminal;
@@ -12,9 +13,9 @@ mod interactive;
1213
mod options;
1314

1415
fn main() -> Result<()> {
15-
use options::*;
16+
use options::Command::*;
1617

17-
let opt: options::Args = argh::from_env();
18+
let opt: options::Args = options::Args::from_args();
1819
let walk_options = dua::WalkOptions {
1920
threads: opt.threads.unwrap_or(0),
2021
byte_format: opt.format.map(Into::into).unwrap_or(ByteFormat::Metric),
@@ -29,8 +30,7 @@ fn main() -> Result<()> {
2930
cross_filesystems: !opt.stay_on_filesystem,
3031
};
3132
let res = match opt.command {
32-
Some(Command::Interactive(Interactive { input }))
33-
| Some(Command::InteractiveAlias(InteractiveAlias { input })) => {
33+
Some(Interactive { input }) => {
3434
let mut terminal = {
3535
let stdout = io::stdout()
3636
.into_raw_mode()
@@ -59,29 +59,23 @@ fn main() -> Result<()> {
5959
// Exit 'quickly' to avoid having to not have to deal with slightly different types in the other match branches
6060
std::process::exit(res.transpose()?.map(|e| e.to_exit_code()).unwrap_or(0));
6161
}
62-
Some(Command::Aggregate(Aggregate {
62+
Some(Aggregate {
6363
input,
6464
no_total,
6565
no_sort,
66-
stats,
67-
}))
68-
| Some(Command::AggregateAlias(AggregateAlias {
69-
input,
70-
no_total,
71-
no_sort,
72-
stats,
73-
})) => {
66+
statistics,
67+
}) => {
7468
let stdout = io::stdout();
7569
let stdout_locked = stdout.lock();
76-
let (res, statistics) = dua::aggregate(
70+
let (res, stats) = dua::aggregate(
7771
stdout_locked,
7872
walk_options,
7973
!no_total,
8074
!no_sort,
8175
paths_from(input)?,
8276
)?;
83-
if stats {
84-
writeln!(io::stderr(), "{:?}", statistics).ok();
77+
if statistics {
78+
writeln!(io::stderr(), "{:?}", stats).ok();
8579
}
8680
res
8781
}

0 commit comments

Comments
 (0)