diff options
author | Marcin Puc <tranzystorek.io@protonmail.com> | 2023-03-02 20:22:58 +0100 |
---|---|---|
committer | Wei Zhang <kweizh@gmail.com> | 2023-03-17 00:12:32 +0800 |
commit | c267a040c6a93b1daa26c51fb61a2e8bc68d913c (patch) | |
tree | d5fd8b338d1667c35aa710d31c171c1f35f24a1e /src/display.rs | |
parent | 7b9290c92c7f3482713a9d9cbd686f6017aeb8d5 (diff) |
Switch arg parsing to clap v4 with derive
Diffstat (limited to 'src/display.rs')
-rw-r--r-- | src/display.rs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/display.rs b/src/display.rs index e55bebe..8e7c251 100644 --- a/src/display.rs +++ b/src/display.rs @@ -446,14 +446,16 @@ fn get_padding_rules(metas: &[Meta], flags: &Flags) -> HashMap<Block, usize> { #[cfg(test)] mod tests { use super::*; + use crate::app::Cli; use crate::color; use crate::color::Colors; use crate::flags::{HyperlinkOption, IconOption, IconTheme as FlagTheme}; use crate::icon::Icons; use crate::meta::{FileType, Name}; use crate::Config; - use crate::{app, flags, sort}; + use crate::{flags, sort}; use assert_fs::prelude::*; + use clap::Parser; use std::path::Path; #[test] @@ -635,8 +637,8 @@ mod tests { #[test] fn test_display_tree_with_all() { let argv = ["lsd", "--tree", "--all"]; - let matches = app::build().try_get_matches_from(argv).unwrap(); - let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); + let cli = Cli::try_parse_from(argv).unwrap(); + let flags = Flags::configure_from(&cli, &Config::with_none()).unwrap(); let dir = assert_fs::TempDir::new().unwrap(); dir.child("one.d").create_dir_all().unwrap(); @@ -668,8 +670,8 @@ mod tests { #[test] fn test_tree_align_subfolder() { let argv = ["lsd", "--tree", "--blocks", "size,name"]; - let matches = app::build().try_get_matches_from(argv).unwrap(); - let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); + let cli = Cli::try_parse_from(argv).unwrap(); + let flags = Flags::configure_from(&cli, &Config::with_none()).unwrap(); let dir = assert_fs::TempDir::new().unwrap(); dir.child("dir").create_dir_all().unwrap(); @@ -708,8 +710,8 @@ mod tests { #[cfg(unix)] fn test_tree_size_first_without_name() { let argv = ["lsd", "--tree", "--blocks", "size,permission"]; - let matches = app::build().try_get_matches_from(argv).unwrap(); - let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); + let cli = Cli::try_parse_from(argv).unwrap(); + let flags = Flags::configure_from(&cli, &Config::with_none()).unwrap(); let dir = assert_fs::TempDir::new().unwrap(); dir.child("dir").create_dir_all().unwrap(); @@ -747,8 +749,8 @@ mod tests { #[test] fn test_tree_edge_before_name() { let argv = ["lsd", "--tree", "--long"]; - let matches = app::build().try_get_matches_from(argv).unwrap(); - let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); + let cli = Cli::try_parse_from(argv).unwrap(); + let flags = Flags::configure_from(&cli, &Config::with_none()).unwrap(); let dir = assert_fs::TempDir::new().unwrap(); dir.child("one.d").create_dir_all().unwrap(); @@ -777,8 +779,8 @@ mod tests { "--blocks", "permission,user,group,size,date,name,inode,links", ]; - let matches = app::build().try_get_matches_from(argv).unwrap(); - let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); + let cli = Cli::try_parse_from(argv).unwrap(); + let flags = Flags::configure_from(&cli, &Config::with_none()).unwrap(); let dir = assert_fs::TempDir::new().unwrap(); dir.child("testdir").create_dir_all().unwrap(); @@ -811,8 +813,8 @@ mod tests { #[test] fn test_grid_no_header_with_empty_meta() { let argv = ["lsd", "--header", "-l"]; - let matches = app::build().try_get_matches_from(argv).unwrap(); - let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); + let cli = Cli::try_parse_from(argv).unwrap(); + let flags = Flags::configure_from(&cli, &Config::with_none()).unwrap(); let dir = assert_fs::TempDir::new().unwrap(); dir.child("testdir").create_dir_all().unwrap(); |