use std::ffi::OsString;
use crate::ProgramExit;
pub use crate::parser::impls::ClapArgsParser;
#[derive(Debug, PartialEq, Default)]
pub struct Args {
pub template_names: Vec<String>,
pub server_url: String,
pub generator_uri: String,
pub lister_uri: String,
pub show_help: bool,
pub show_version: bool,
pub show_author: bool,
pub show_list: bool,
pub check_template_names: bool,
}
impl Args {
pub fn with_template_names(mut self, template_names: Vec<String>) -> Self {
self.template_names = template_names;
self
}
pub fn with_server_url(mut self, server_url: &str) -> Self {
self.server_url = server_url.to_string();
self
}
pub fn with_generator_uri(mut self, generator_uri: &str) -> Self {
self.generator_uri = generator_uri.to_string();
self
}
pub fn with_lister_uri(mut self, lister_uri: &str) -> Self {
self.lister_uri = lister_uri.to_string();
self
}
pub fn with_show_list(mut self, show_list: bool) -> Self {
self.show_list = show_list;
self
}
pub fn with_check_template_names(
mut self,
check_template_names: bool,
) -> Self {
self.check_template_names = check_template_names;
self
}
}
pub trait ArgsParser {
fn parse(&self, args: impl IntoIterator<Item = OsString>) -> Args;
fn try_parse(
&self,
args: impl IntoIterator<Item = OsString>,
) -> Result<Args, ProgramExit>;
}