2015-07-19 06:08:38 +08:00
|
|
|
use std::path::{Path, PathBuf};
|
2015-07-17 00:20:36 +08:00
|
|
|
|
2015-07-19 06:08:38 +08:00
|
|
|
#[derive(Debug, Clone)]
|
2015-07-17 00:20:36 +08:00
|
|
|
pub struct BookConfig {
|
2015-07-19 06:08:38 +08:00
|
|
|
title: String,
|
|
|
|
author: String,
|
2015-07-17 00:20:36 +08:00
|
|
|
dest: PathBuf,
|
|
|
|
src: PathBuf,
|
2015-07-18 06:04:20 +08:00
|
|
|
indent_spaces: i32,
|
2015-07-17 00:20:36 +08:00
|
|
|
multilingual: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl BookConfig {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
BookConfig {
|
2015-07-19 06:08:38 +08:00
|
|
|
title: String::new(),
|
|
|
|
author: String::new(),
|
2015-07-17 00:20:36 +08:00
|
|
|
dest: PathBuf::from("book"),
|
|
|
|
src: PathBuf::from("src"),
|
2015-07-18 06:04:20 +08:00
|
|
|
indent_spaces: 4,
|
2015-07-17 00:20:36 +08:00
|
|
|
multilingual: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-19 06:08:38 +08:00
|
|
|
pub fn dest(&self) -> &Path {
|
|
|
|
&self.dest
|
2015-07-17 00:20:36 +08:00
|
|
|
}
|
|
|
|
|
2015-07-19 06:08:38 +08:00
|
|
|
pub fn set_dest(&mut self, dest: &Path) -> &mut Self {
|
|
|
|
self.dest = dest.to_owned();
|
2015-07-17 00:20:36 +08:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2015-07-19 06:08:38 +08:00
|
|
|
pub fn src(&self) -> &Path {
|
|
|
|
&self.src
|
2015-07-17 00:20:36 +08:00
|
|
|
}
|
|
|
|
|
2015-07-19 06:08:38 +08:00
|
|
|
pub fn set_src(&mut self, src: &Path) -> &mut Self {
|
|
|
|
self.src = src.to_owned();
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_title(&mut self, title: &str) -> &mut Self {
|
|
|
|
self.title = title.to_owned();
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_author(&mut self, author: &str) -> &mut Self {
|
|
|
|
self.author = author.to_owned();
|
2015-07-17 00:20:36 +08:00
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|