yazi/yazi-config/src/manager/manager.rs
Chris Zarate 3533ac20f7
feat: add title_format manager config option (#1281)
Co-authored-by: sxyazi <sxyazi@gmail.com>
2024-08-02 16:05:58 +08:00

43 lines
918 B
Rust

use std::str::FromStr;
use serde::{Deserialize, Serialize};
use validator::Validate;
use super::{ManagerRatio, MouseEvents, SortBy};
#[derive(Debug, Deserialize, Serialize, Validate)]
pub struct Manager {
pub ratio: ManagerRatio,
// Sorting
pub sort_by: SortBy,
pub sort_sensitive: bool,
pub sort_reverse: bool,
pub sort_dir_first: bool,
pub sort_translit: bool,
// Display
#[validate(length(min = 1, max = 20, message = "must be between 1 and 20 characters"))]
pub linemode: String,
pub show_hidden: bool,
pub show_symlink: bool,
pub scrolloff: u8,
pub mouse_events: MouseEvents,
pub title_format: String,
}
impl FromStr for Manager {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
#[derive(Deserialize)]
struct Outer {
manager: Manager,
}
let manager = toml::from_str::<Outer>(s)?.manager;
manager.validate()?;
Ok(manager)
}
}