@@ -4,6 +4,7 @@ use crate::interactive::{Interaction, TerminalApp};
44use anyhow:: { Context , Result } ;
55use dua:: { ByteFormat , Color , TraversalSorting } ;
66use std:: { fs, io, io:: Write , path:: PathBuf , process} ;
7+ use structopt:: StructOpt ;
78use termion:: { raw:: IntoRawMode , screen:: AlternateScreen } ;
89use tui:: backend:: TermionBackend ;
910use tui_react:: Terminal ;
@@ -12,9 +13,9 @@ mod interactive;
1213mod options;
1314
1415fn 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