diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-06 14:32:07 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-06 14:32:07 +0800 |
commit | 464829e11f5d6d63019ec167e2e1b1b7c0061f0a (patch) | |
tree | 32a40d4297093f964747387e5e0c9229e9544ab9 | |
parent | d0c362ae0f0f7ff4d49d899591c6cbb205e6b191 (diff) |
Make interactive mode optional, allow selection of backend for windows, unix
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 20 | ||||
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | src/main.rs | 10 | ||||
-rw-r--r-- | src/options.rs | 1 |
5 files changed, 31 insertions, 11 deletions
@@ -205,6 +205,7 @@ checksum = "74ba604c40d092aa60a7a17f6cf148f2ede84f4372e2b691d49fdd89820e7846" dependencies = [ "crossterm", "flume", + "termion", "tui", "tui-react 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -238,7 +239,6 @@ dependencies = [ "flume", "itertools", "jwalk", - "log", "num_cpus", "open", "petgraph", @@ -9,25 +9,33 @@ description = "A tool to conveniently learn about the disk usage of directories, license = "MIT" include = ["src/**/*", "Cargo.*", "LICENSE", "README.md", "CHANGELOG.md", "!**/*_test/*"] +[features] +default = ["tui-crossplatform"] +tui-unix = ["crosstermion/tui-react-termion", "tui-shared"] +tui-crossplatform = ["crosstermion/tui-react-crossterm", "tui-shared"] + +tui-shared = ["crosstermion/input-thread-flume", "tui", "tui-react", "open", "unicode-segmentation"] + [dependencies] structopt = "0.3.15" jwalk = "0.5.0" byte-unit = "4" atty = "0.2.11" -tui = "0.9.1" petgraph = "0.5" itertools = "0.9.0" -open = "1.2.2" -log = "0.4.6" -tui-react = "0.4" num_cpus = "1.10.0" -unicode-segmentation = "1.3.0" filesize = "0.2.0" flume = {version = "0.7.1", default-features = false} anyhow = "1.0.31" -crosstermion = { version = "0.1.3", default-features = false, features = ["tui-react-crossterm", "input-thread-flume"]} colored = "1.9.3" +# 'tui' related +unicode-segmentation = { version = "1.3.0", optional = true } +crosstermion = { optional = true, version = "0.1.3", default-features = false } +tui = { version = "0.9.1", optional = true } +tui-react = { version = "0.4", optional = true } +open = { version = "1.2.2", optional = true } + [[bin]] name="dua" path="src/main.rs" @@ -29,7 +29,14 @@ profile: target/release/dua ## run callgrind and annotate its output - linux onl benchmark: target/release/dua ## see how fast things are, powered by hyperfine hyperfine '$<' -tests: unit-tests journey-tests ## run all tests +tests: check unit-tests journey-tests ## run all tests + +check:## run all unit tests + cargo check --all + cargo check --all-features + cargo check --no-default-features + cargo check --features tui-unix + cargo check --features tui-crossplatform unit-tests: ## run all unit tests cargo test --all diff --git a/src/main.rs b/src/main.rs index 91d0fce..a47fc22 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,11 @@ #![forbid(unsafe_code)] #![allow(clippy::match_bool)] -use crate::interactive::{Interaction, TerminalApp}; -use anyhow::{Context, Result}; -use crosstermion::terminal::{tui::new_terminal, AlternateRawScreen}; +use anyhow::Result; use dua::{ByteFormat, Color, TraversalSorting}; use std::{fs, io, io::Write, path::PathBuf, process}; use structopt::StructOpt; +#[cfg(any(feature = "tui-unix", feature = "tui-crossplatform"))] mod interactive; mod options; @@ -28,7 +27,12 @@ fn main() -> Result<()> { cross_filesystems: !opt.stay_on_filesystem, }; let res = match opt.command { + #[cfg(any(feature = "tui-unix", feature = "tui-crossplatform"))] Some(Interactive { input }) => { + use crate::interactive::{Interaction, TerminalApp}; + use anyhow::Context; + use crosstermion::terminal::{tui::new_terminal, AlternateRawScreen}; + let mut terminal = new_terminal( AlternateRawScreen::try_from(io::stdout()) .with_context(|| "Interactive mode requires a connected terminal")?, diff --git a/src/options.rs b/src/options.rs index 992f823..a7d7618 100644 --- a/src/options.rs +++ b/src/options.rs @@ -72,6 +72,7 @@ pub struct Args { #[derive(Debug, StructOpt)] pub enum Command { /// Launch the terminal user interface + #[cfg(any(feature = "tui-unix", feature = "tui-crossplatform"))] #[structopt(name = "interactive", visible_alias = "i")] Interactive { /// One or more input files or directories. If unset, we will use all entries in the current working directory. |