lotabout / skim

Fuzzy Finder in rust!
MIT License
5.1k stars 183 forks source link

Refactor to clap-4 with derive #491

Closed TD-Sky closed 1 year ago

TD-Sky commented 1 year ago

The construction of CLI

Use clap-4.0.18 with derive feature.

The only way I know to reserve the old style of help information which mimicked fzf is using Command::override_help with the help information written manually.

I write help for every argument and then modify the auto generated help information to get the final one.

To developers:

  1. crate::cli::Cli could parse string to type value(s) now, so it's no need to parse string in succeeding functions.

  2. These enums of arguments implementing ValueEnum,

    • crate::engine::fuzzy::FuzzyAlgorithm
    • crate::item::RankCriteria
    • crate::CaseMatching
    • And new enum crate::Layout
  3. Some fields of crate::options::SkimOptions change types,

    • expect: Option<&str> => Vec<&str>
    • tiebreak: Option<String> => Vec<RankCriteria>
    • delimiter: Option<&str> => &str
    • color: Option<&str> => Vec<&str>
    • margin: Option<&str> => Vec<&str>
    • tabstop: Option<&str> => Option<usize>
    • layout: &'a str => Layout
  4. For the above reasons, the ways to use SkimOptions change,

    • In crate::input::Input,

      • Before: parse_expect_keys(&mut self, keys: Option<&str>)
      • Now: parse_expect_keys(&mut self, keys: &[&str])
    • In crate::item, remove parse_criteria;

    • In crate::theme::ColorTheme,

      • Before: from_options(color: &str) -> Self
      • Now: from_options(color: &[&str]) -> Self
    • In crate::util,

      • Before: parse_margin(margins: &str) -> (Size, Size, Size, Size)
      • Now: parse_margin(margins: &[&str]) -> (Size, Size, Size, Size)
    • See crate::header::with_options, crate::model, crate::selection;

To users of library

In skim::prelude::SkimOptionsBuilder

In skim::prelude::SkimItemReaderOption

TD-Sky commented 1 year ago

It maybe quite a long time that this PR can't be completed because of the issue#4501 in clap.

TD-Sky commented 1 year ago

So I want to close it at present.