diff options
author | Denys Séguret <cano.petrole@gmail.com> | 2022-09-23 14:35:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-23 14:35:35 +0200 |
commit | a83733515765a918e1ca9fbf413a5c75f3bced2c (patch) | |
tree | b707f3b3e62a4e81d5424dd35fc5623eae080a82 | |
parent | 0f5193f31eeeb9f6e721806fca8f3acde6b52da9 (diff) | |
parent | 3055c88a481119e40ea072c374d21a8fd08b5bb6 (diff) |
Merge pull request #605 from Canop/issue-602
--sort-by-type-dirs-first --sort-by-type-dirs-last
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | Cargo.lock | 4 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/cli/args.rs | 12 | ||||
-rw-r--r-- | src/tree/tree_options.rs | 6 |
5 files changed, 22 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f836d3e..e8a22f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### next - with `show_matching_characters_on_path_searches: false`, it's possible to show only file names even when searching paths - Fix #490 +- `--sort-by-type-dirs-first` and `--sort-by-type-dirs-last` - Fix #602 ### v1.14.3 - 2022-09-12 <a name="v1.14.3"></a> @@ -1724,9 +1724,9 @@ dependencies = [ [[package]] name = "splitty" -version = "0.1.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8190298e89d4080e9c025535f73cacec4d51ff4495819dd8fdf1ae374c75ee80" +checksum = "53060f84ce26aec49454cc575f949876d928ea954ea1bd6071a9b2602d8c7caa" [[package]] name = "str-buf" @@ -53,7 +53,7 @@ regex = "1.5" secular = { version = "1.0", features = ["normalization"] } serde = { version = "1.0", features = ["derive"] } smallvec = "1.9" -splitty = "0.1" +splitty = "1.0" strict = "0.1.4" syntect = { package = "syntect-no-panic", version = "4.6.1" } # see issue #485 tempfile = "3.2" diff --git a/src/cli/args.rs b/src/cli/args.rs index 8ef4b89..5f85a02 100644 --- a/src/cli/args.rs +++ b/src/cli/args.rs @@ -88,6 +88,18 @@ pub struct Args { /// Sort by size (only show one level of the tree) pub sort_by_size: bool, + #[clap(long, action)] + /// Same as sort-by-type-dirs-first + pub sort_by_type: bool, + + #[clap(long, action)] + /// Sort by type, directories first (only show one level of the tree) + pub sort_by_type_dirs_first: bool, + + #[clap(long, action)] + /// Sort by type, directories last (only show one level of the tree) + pub sort_by_type_dirs_last: bool, + /// Sort by size, show ignored and hidden files #[clap(short, long, action)] pub whale_spotting: bool, diff --git a/src/tree/tree_options.rs b/src/tree/tree_options.rs index 5cd8584..b87142d 100644 --- a/src/tree/tree_options.rs +++ b/src/tree/tree_options.rs @@ -169,6 +169,12 @@ impl TreeOptions { self.sort = Sort::Size; self.show_sizes = true; } + if cli_args.sort_by_type_dirs_first || cli_args.sort_by_type { + self.sort = Sort::TypeDirsFirst; + } + if cli_args.sort_by_type_dirs_last { + self.sort = Sort::TypeDirsLast; + } if cli_args.no_sort { self.sort = Sort::None; } |