diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-01 13:51:12 +0530 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-01 13:51:12 +0530 |
commit | 8b2ef49bf9f37d0e126fa68115175fe2cf82aaf5 (patch) | |
tree | 6bd02c6dc8d17cb1e31746b74c497d434541324c /src/main.rs | |
parent | 961b743773da2a5112bd4ab70554c50b03ded3ad (diff) |
Pull out all modules into files
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 62 |
1 files changed, 1 insertions, 61 deletions
diff --git a/src/main.rs b/src/main.rs index 57070be..89d17fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,67 +9,7 @@ use failure::Error; use failure_tools::ok_or_exit; use std::{io, path::PathBuf, process}; -mod options { - use dua::ByteFormat as LibraryByteFormat; - use std::path::PathBuf; - use structopt::{clap::arg_enum, StructOpt}; - - arg_enum! { - #[derive(PartialEq, Debug)] - pub enum ByteFormat { - HumanMetric, - HumanBinary, - Bytes - } - } - - impl From<ByteFormat> for LibraryByteFormat { - fn from(input: ByteFormat) -> Self { - match input { - ByteFormat::HumanMetric => LibraryByteFormat::Metric, - ByteFormat::HumanBinary => LibraryByteFormat::Binary, - ByteFormat::Bytes => LibraryByteFormat::Bytes, - } - } - } - - #[derive(Debug, StructOpt)] - #[structopt(name = "dua", about = "A tool to learn about disk usage, fast!")] - pub struct Args { - #[structopt(subcommand)] - pub command: Option<Command>, - - /// The amount of threads to use. Defaults to the amount of logical processors. - /// Set to 1 to use only a single thread. - #[structopt(short = "t", long = "threads")] - pub threads: Option<usize>, - - /// The format with which to print byte counts. - /// HumanMetric - uses 1000 as base (default) - /// HumanBinary - uses 1024 as base - /// Bytes - plain bytes without any formatting - #[structopt(short = "f", long = "format")] - pub format: Option<ByteFormat>, - - /// One or more input files. If unset, we will assume the current directory - #[structopt(parse(from_os_str))] - pub input: Vec<PathBuf>, - } - - #[derive(Debug, StructOpt)] - pub enum Command { - /// Aggregrate the consumed space of one or more directories or files - #[structopt(name = "aggregate", alias = "a")] - Aggregate { - /// If set, no total column will be computed for multiple inputs - #[structopt(long = "no-total")] - no_total: bool, - /// One or more input files. If unset, we will assume the current directory - #[structopt(parse(from_os_str))] - input: Vec<PathBuf>, - }, - } -} +mod options; fn run() -> Result<(), Error> { use options::Command::*; |