use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Opts {
#[serde(default)]
pub(crate) mobile_to_desktop: bool,
#[serde(default)]
pub(crate) ignore_unknown_versions: bool,
#[serde(default)]
pub(crate) config: Option<String>,
#[serde(default)]
pub(crate) env: Option<String>,
#[serde(default)]
pub(crate) path: Option<String>,
#[serde(default)]
pub(crate) throw_on_missing: bool,
}
impl Opts {
pub fn new() -> Self {
Self::default()
}
pub fn mobile_to_desktop(&mut self, flag: bool) -> &mut Self {
self.mobile_to_desktop = flag;
self
}
pub fn ignore_unknown_versions(&mut self, flag: bool) -> &mut Self {
self.ignore_unknown_versions = flag;
self
}
pub fn config<S: AsRef<str>>(&mut self, config_path: S) -> &mut Self {
self.config = Some(config_path.as_ref().to_string());
self
}
pub fn env<S: AsRef<str>>(&mut self, env: S) -> &mut Self {
self.env = Some(env.as_ref().to_string());
self
}
pub fn path<S: AsRef<str>>(&mut self, path: S) -> &mut Self {
self.path = Some(path.as_ref().to_string());
self
}
pub fn throw_on_missing(&mut self, flag: bool) -> &mut Self {
self.throw_on_missing = flag;
self
}
}