summaryrefslogtreecommitdiffstats
path: root/src/options.rs
diff options
context:
space:
mode:
authorSebastian Thiel <sthiel@thoughtworks.com>2019-06-01 13:51:12 +0530
committerSebastian Thiel <sthiel@thoughtworks.com>2019-06-01 13:51:12 +0530
commit8b2ef49bf9f37d0e126fa68115175fe2cf82aaf5 (patch)
tree6bd02c6dc8d17cb1e31746b74c497d434541324c /src/options.rs
parent961b743773da2a5112bd4ab70554c50b03ded3ad (diff)
Pull out all modules into files
Diffstat (limited to 'src/options.rs')
-rw-r--r--src/options.rs59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/options.rs b/src/options.rs
new file mode 100644
index 0000000..6136109
--- /dev/null
+++ b/src/options.rs
@@ -0,0 +1,59 @@
+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>,
+ },
+}