refactor: alphabets.rs -> textbuf/alphabet.rs

This commit is contained in:
graelo 2021-03-20 07:46:43 +01:00
parent 7d4d9a8824
commit 2c3c7a5456
5 changed files with 16 additions and 14 deletions

View file

@ -1,9 +1,3 @@
use clap::Clap;
use std::collections::HashMap;
use std::path;
use std::str::FromStr;
pub mod alphabets;
pub mod error;
pub mod output_destination;
pub mod regexes;
@ -11,6 +5,13 @@ pub mod textbuf;
pub mod tmux;
pub mod ui;
use clap::Clap;
use std::collections::HashMap;
use std::path;
use std::str::FromStr;
use crate::textbuf::alphabet;
/// Run copyrat on an input string `buffer`, configured by `Opt`.
///
/// # Note
@ -72,8 +73,8 @@ pub struct CliOpt {
///
/// "qwerty", "dvorak-homerow", "azerty-right-hand".
#[clap(short = 'k', long, default_value = "dvorak",
parse(try_from_str = alphabets::parse_alphabet))]
alphabet: alphabets::Alphabet,
parse(try_from_str = alphabet::parse_alphabet))]
alphabet: alphabet::Alphabet,
/// Use all available regex patterns.
#[clap(short = 'A', long = "--all-patterns")]
@ -172,7 +173,7 @@ impl CliOpt {
for (name, value) in options {
match name.as_ref() {
"@copyrat-alphabet" => {
self.alphabet = alphabets::parse_alphabet(value)?;
self.alphabet = alphabet::parse_alphabet(value)?;
}
"@copyrat-pattern-name" => {
self.named_patterns = vec![regexes::parse_pattern_name(value)?]