mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-11 02:40:26 +03:00
Refacto on request options.
This commit is contained in:
parent
f315820280
commit
0efaacc12d
@ -20,7 +20,7 @@ use crate::runner::template;
|
||||
use crate::runner::{Error, RunnerOptions, Value};
|
||||
use crate::util::logger::{Logger, Verbosity};
|
||||
use hurl_core::ast::{
|
||||
Entry, EntryOption, Float, SectionValue, VariableDefinition, VariableOption, VariableValue,
|
||||
Entry, EntryOption, Float, OptionKind, SectionValue, VariableDefinition, VariableValue,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
use std::time::Duration;
|
||||
@ -44,80 +44,55 @@ pub fn get_entry_options(
|
||||
|
||||
for section in &entry.request.sections {
|
||||
if let SectionValue::Options(options) = §ion.value {
|
||||
for option in options {
|
||||
match option {
|
||||
EntryOption::CaCertificate(option) => {
|
||||
runner_options.cacert_file = Some(option.filename.value.clone());
|
||||
logger.debug(format!("cacert: {}", option.filename.value).as_str());
|
||||
for option in options.iter() {
|
||||
match &option.kind {
|
||||
OptionKind::CaCertificate(filename) => {
|
||||
runner_options.cacert_file = Some(filename.value.clone())
|
||||
}
|
||||
EntryOption::ClientCert(option) => {
|
||||
runner_options.client_cert_file = Some(option.filename.value.clone());
|
||||
logger.debug(format!("cert: {}", option.filename.value).as_str());
|
||||
OptionKind::ClientCert(filename) => {
|
||||
runner_options.client_cert_file = Some(filename.value.clone())
|
||||
}
|
||||
EntryOption::ClientKey(option) => {
|
||||
runner_options.client_key_file = Some(option.filename.value.clone());
|
||||
logger.debug(format!("key: {}", option.filename.value).as_str());
|
||||
OptionKind::ClientKey(filename) => {
|
||||
runner_options.client_key_file = Some(filename.value.clone())
|
||||
}
|
||||
EntryOption::Compressed(option) => {
|
||||
runner_options.compressed = option.value;
|
||||
logger.debug(format!("compressed: {}", option.value).as_str());
|
||||
}
|
||||
EntryOption::FollowLocation(option) => {
|
||||
runner_options.follow_location = option.value;
|
||||
logger.debug(format!("location: {}", option.value).as_str());
|
||||
}
|
||||
EntryOption::Insecure(option) => {
|
||||
runner_options.insecure = option.value;
|
||||
logger.debug(format!("insecure: {}", option.value).as_str());
|
||||
}
|
||||
EntryOption::MaxRedirect(option) => {
|
||||
runner_options.max_redirect = Some(option.value);
|
||||
logger.debug(format!("max-redirs: {}", option.value).as_str());
|
||||
}
|
||||
EntryOption::PathAsIs(option) => {
|
||||
runner_options.path_as_is = option.value;
|
||||
logger.debug(format!("path-as-is: {}", option.value).as_str());
|
||||
}
|
||||
EntryOption::Proxy(option) => {
|
||||
runner_options.proxy = Some(option.value.clone());
|
||||
logger.debug(format!("proxy: {}", option.value).as_str());
|
||||
}
|
||||
EntryOption::Resolve(option) => {
|
||||
OptionKind::Compressed(value) => runner_options.compressed = *value,
|
||||
OptionKind::Insecure(value) => runner_options.insecure = *value,
|
||||
OptionKind::FollowLocation(value) => runner_options.follow_location = *value,
|
||||
OptionKind::MaxRedirect(value) => runner_options.max_redirect = Some(*value),
|
||||
OptionKind::PathAsIs(value) => runner_options.path_as_is = *value,
|
||||
OptionKind::Proxy(value) => runner_options.proxy = Some(value.clone()),
|
||||
OptionKind::Resolve(value) => {
|
||||
let mut resolves = runner_options.resolves;
|
||||
resolves.push(option.value.clone());
|
||||
resolves.push(value.clone());
|
||||
runner_options.resolves = resolves;
|
||||
logger.debug(format!("resolve: {}", option.value).as_str());
|
||||
}
|
||||
EntryOption::Retry(option) => {
|
||||
runner_options.retry = option.value;
|
||||
logger.debug(format!("retry: {}", option.value).as_str());
|
||||
OptionKind::Retry(value) => runner_options.retry = *value,
|
||||
OptionKind::RetryInterval(value) => {
|
||||
runner_options.retry_interval = Duration::from_millis(*value)
|
||||
}
|
||||
EntryOption::RetryInterval(option) => {
|
||||
runner_options.retry_interval = Duration::from_millis(option.value);
|
||||
logger.debug(format!("retry-interval: {}", option.value).as_str());
|
||||
}
|
||||
EntryOption::Variable(VariableOption {
|
||||
value: VariableDefinition { name, value, .. },
|
||||
..
|
||||
}) => {
|
||||
OptionKind::Variable(VariableDefinition { name, value, .. }) => {
|
||||
let value = eval_variable_value(value, variables)?;
|
||||
logger.debug(format!("variable: {}={}", name, value).as_str());
|
||||
variables.insert(name.clone(), value);
|
||||
}
|
||||
EntryOption::Verbose(option) => {
|
||||
logger.debug(format!("verbose: {}", option.value).as_str());
|
||||
}
|
||||
|
||||
EntryOption::VeryVerbose(option) => {
|
||||
logger.debug(format!("very-verbose: {}", option.value).as_str());
|
||||
}
|
||||
// verbose and very-verbose option have been previously processed as thy
|
||||
// can impact the logging.
|
||||
OptionKind::Verbose(_) => {}
|
||||
OptionKind::VeryVerbose(_) => {}
|
||||
}
|
||||
log_option(option, logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(runner_options)
|
||||
}
|
||||
|
||||
/// Logs an entry option.
|
||||
fn log_option(option: &EntryOption, logger: &Logger) {
|
||||
let name = option.kind.name();
|
||||
let value = option.kind.value_as_str();
|
||||
logger.debug(&format!("{name}: {value}"));
|
||||
}
|
||||
|
||||
/// Returns [`true`] if this `entry` has an Option section, [`false`] otherwise.
|
||||
fn has_options(entry: &Entry) -> bool {
|
||||
entry
|
||||
@ -134,16 +109,16 @@ pub fn get_entry_verbosity(entry: &Entry, verbosity: &Option<Verbosity>) -> Opti
|
||||
for section in &entry.request.sections {
|
||||
if let SectionValue::Options(options) = §ion.value {
|
||||
for option in options {
|
||||
match option {
|
||||
EntryOption::Verbose(option) => {
|
||||
verbosity = if option.value {
|
||||
match &option.kind {
|
||||
OptionKind::Verbose(value) => {
|
||||
verbosity = if *value {
|
||||
Some(Verbosity::Verbose)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
EntryOption::VeryVerbose(option) => {
|
||||
verbosity = if option.value {
|
||||
OptionKind::VeryVerbose(value) => {
|
||||
verbosity = if *value {
|
||||
Some(Verbosity::VeryVerbose)
|
||||
} else {
|
||||
None
|
||||
|
@ -708,172 +708,76 @@ pub struct Variable {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum EntryOption {
|
||||
CaCertificate(CaCertificateOption),
|
||||
ClientCert(ClientCertOption),
|
||||
ClientKey(ClientKeyOption),
|
||||
Compressed(CompressedOption),
|
||||
Insecure(InsecureOption),
|
||||
FollowLocation(FollowLocationOption),
|
||||
MaxRedirect(MaxRedirectOption),
|
||||
PathAsIs(PathAsIsOption),
|
||||
Proxy(ProxyOption),
|
||||
Resolve(ResolveOption),
|
||||
Retry(RetryOption),
|
||||
RetryInterval(RetryIntervalOption),
|
||||
Variable(VariableOption),
|
||||
Verbose(VerboseOption),
|
||||
VeryVerbose(VeryVerboseOption),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CompressedOption {
|
||||
pub struct EntryOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: bool,
|
||||
pub kind: OptionKind,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct InsecureOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: bool,
|
||||
pub line_terminator0: LineTerminator,
|
||||
pub enum OptionKind {
|
||||
CaCertificate(Filename),
|
||||
ClientCert(Filename),
|
||||
ClientKey(Filename),
|
||||
Compressed(bool),
|
||||
Insecure(bool),
|
||||
FollowLocation(bool),
|
||||
MaxRedirect(usize),
|
||||
PathAsIs(bool),
|
||||
Proxy(String),
|
||||
Resolve(String),
|
||||
Retry(Retry),
|
||||
RetryInterval(u64),
|
||||
Variable(VariableDefinition),
|
||||
Verbose(bool),
|
||||
VeryVerbose(bool),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CaCertificateOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub filename: Filename,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
impl OptionKind {
|
||||
pub fn name(&self) -> &'static str {
|
||||
match self {
|
||||
OptionKind::CaCertificate(_) => "cacert",
|
||||
OptionKind::ClientCert(_) => "cert",
|
||||
OptionKind::ClientKey(_) => "key",
|
||||
OptionKind::Compressed(_) => "compressed",
|
||||
OptionKind::Insecure(_) => "insecure",
|
||||
OptionKind::FollowLocation(_) => "location",
|
||||
OptionKind::MaxRedirect(_) => "max-redirs",
|
||||
OptionKind::PathAsIs(_) => "path-as-is",
|
||||
OptionKind::Proxy(_) => "proxy",
|
||||
OptionKind::Resolve(_) => "resolve",
|
||||
OptionKind::Retry(_) => "retry",
|
||||
OptionKind::RetryInterval(_) => "retry-interval",
|
||||
OptionKind::Variable(_) => "variable",
|
||||
OptionKind::Verbose(_) => "verbose",
|
||||
OptionKind::VeryVerbose(_) => "very-verbose",
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ClientCertOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub filename: Filename,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ClientKeyOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub filename: Filename,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct PathAsIsOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: bool,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ProxyOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: String,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct RetryIntervalOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: u64,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ResolveOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: String,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct RetryOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: Retry,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct VerboseOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: bool,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct VeryVerboseOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: bool,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct FollowLocationOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: bool,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct MaxRedirectOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: usize,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct VariableOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: VariableDefinition,
|
||||
pub line_terminator0: LineTerminator,
|
||||
pub fn value_as_str(&self) -> String {
|
||||
match self {
|
||||
OptionKind::CaCertificate(filename) => filename.value.clone(),
|
||||
OptionKind::ClientCert(filename) => filename.value.clone(),
|
||||
OptionKind::ClientKey(filename) => filename.value.clone(),
|
||||
OptionKind::Compressed(value) => value.to_string(),
|
||||
OptionKind::Insecure(value) => value.to_string(),
|
||||
OptionKind::FollowLocation(value) => value.to_string(),
|
||||
OptionKind::MaxRedirect(value) => value.to_string(),
|
||||
OptionKind::PathAsIs(value) => value.to_string(),
|
||||
OptionKind::Proxy(value) => value.clone(),
|
||||
OptionKind::Resolve(value) => value.clone(),
|
||||
OptionKind::Retry(value) => value.to_string(),
|
||||
OptionKind::RetryInterval(value) => value.to_string(),
|
||||
OptionKind::Variable(VariableDefinition { name, value, .. }) => {
|
||||
format!("{name}={value}")
|
||||
}
|
||||
OptionKind::Verbose(value) => value.to_string(),
|
||||
OptionKind::VeryVerbose(value) => value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
|
@ -200,193 +200,41 @@ impl HtmlFormatter {
|
||||
self.fmt_lt(&kv.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_entry_option(&mut self, entry_option: &EntryOption) {
|
||||
match entry_option {
|
||||
EntryOption::CaCertificate(option) => self.fmt_ca_certificate_option(option),
|
||||
EntryOption::ClientCert(option) => self.fmt_client_cert_option(option),
|
||||
EntryOption::ClientKey(option) => self.fmt_client_key_option(option),
|
||||
EntryOption::Compressed(option) => self.fmt_compressed_option(option),
|
||||
EntryOption::Insecure(option) => self.fmt_insecure_option(option),
|
||||
EntryOption::FollowLocation(option) => self.fmt_follow_location_option(option),
|
||||
EntryOption::MaxRedirect(option) => self.fmt_max_redirect_option(option),
|
||||
EntryOption::PathAsIs(option) => self.fmt_path_as_is_option(option),
|
||||
EntryOption::Proxy(option) => self.fmt_proxy_option(option),
|
||||
EntryOption::Resolve(option) => self.fmt_resolve_option(option),
|
||||
EntryOption::Retry(option) => self.fmt_retry_option(option),
|
||||
EntryOption::RetryInterval(option) => self.fmt_retry_interval_option(option),
|
||||
EntryOption::Variable(option) => self.fmt_variable_option(option),
|
||||
EntryOption::Verbose(option) => self.fmt_verbose_option(option),
|
||||
EntryOption::VeryVerbose(option) => self.fmt_very_verbose_option(option),
|
||||
fn fmt_entry_option(&mut self, option: &EntryOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string(option.kind.name());
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
match &option.kind {
|
||||
OptionKind::CaCertificate(filename) => self.fmt_filename(filename),
|
||||
OptionKind::ClientCert(filename) => self.fmt_filename(filename),
|
||||
OptionKind::ClientKey(filename) => self.fmt_filename(filename),
|
||||
OptionKind::Compressed(value) => self.fmt_bool(*value),
|
||||
OptionKind::Insecure(value) => self.fmt_bool(*value),
|
||||
OptionKind::FollowLocation(value) => self.fmt_bool(*value),
|
||||
OptionKind::MaxRedirect(value) => self.fmt_number(value),
|
||||
OptionKind::PathAsIs(value) => self.fmt_bool(*value),
|
||||
OptionKind::Proxy(value) => self.fmt_string(value),
|
||||
OptionKind::Resolve(value) => self.fmt_string(value),
|
||||
OptionKind::Retry(value) => self.fmt_retry(value),
|
||||
OptionKind::RetryInterval(value) => self.fmt_number(value),
|
||||
OptionKind::Variable(value) => self.fmt_variable_definition(value),
|
||||
OptionKind::Verbose(value) => self.fmt_bool(*value),
|
||||
OptionKind::VeryVerbose(value) => self.fmt_bool(*value),
|
||||
};
|
||||
}
|
||||
|
||||
fn fmt_compressed_option(&mut self, option: &CompressedOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("compressed");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_bool(option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_insecure_option(&mut self, option: &InsecureOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("insecure");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_bool(option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_ca_certificate_option(&mut self, option: &CaCertificateOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("cacert");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_filename(&option.filename);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_client_cert_option(&mut self, option: &ClientCertOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("cert");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_filename(&option.filename);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_client_key_option(&mut self, option: &ClientKeyOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("key");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_filename(&option.filename);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_follow_location_option(&mut self, option: &FollowLocationOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("location");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_bool(option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_max_redirect_option(&mut self, option: &MaxRedirectOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("max-redirs");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_number(option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_path_as_is_option(&mut self, option: &PathAsIsOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("path-as-is");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_bool(option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_proxy_option(&mut self, option: &ProxyOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("proxy");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_string(&option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_resolve_option(&mut self, option: &ResolveOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("resolve");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_string(&option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_retry_option(&mut self, option: &RetryOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("retry");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_retry(option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_retry_interval_option(&mut self, option: &RetryIntervalOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("retry-interval");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_number(option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_variable_option(&mut self, option: &VariableOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("variable");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_variable_definition(&option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
fn fmt_retry(&mut self, retry: &Retry) {
|
||||
match retry {
|
||||
Retry::Finite(n) => self.fmt_number(n),
|
||||
Retry::Infinite => self.fmt_number(-1),
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
||||
fn fmt_variable_definition(&mut self, option: &VariableDefinition) {
|
||||
@ -406,32 +254,6 @@ impl HtmlFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
fn fmt_verbose_option(&mut self, option: &VerboseOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("verbose");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_bool(option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_very_verbose_option(&mut self, option: &VeryVerboseOption) {
|
||||
self.fmt_lts(&option.line_terminators);
|
||||
self.fmt_span_open("line");
|
||||
self.fmt_space(&option.space0);
|
||||
self.fmt_string("very-verbose");
|
||||
self.fmt_space(&option.space1);
|
||||
self.buffer.push(':');
|
||||
self.fmt_space(&option.space2);
|
||||
self.fmt_bool(option.value);
|
||||
self.fmt_span_close();
|
||||
self.fmt_lt(&option.line_terminator0);
|
||||
}
|
||||
|
||||
fn fmt_multipart_param(&mut self, param: &MultipartParam) {
|
||||
match param {
|
||||
MultipartParam::Param(param) => self.fmt_kv(param),
|
||||
@ -982,14 +804,6 @@ impl HtmlFormatter {
|
||||
self.fmt_lt(line_terminator);
|
||||
}
|
||||
}
|
||||
|
||||
fn fmt_retry(&mut self, retry: Retry) {
|
||||
match retry {
|
||||
Retry::Finite(n) => self.fmt_span("number", &n.to_string()),
|
||||
Retry::Infinite => self.fmt_span("number", "-1"),
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn escape_xml(s: &str) -> String {
|
||||
|
@ -355,224 +355,125 @@ fn assert(reader: &mut Reader) -> ParseResult<'static, Assert> {
|
||||
}
|
||||
|
||||
fn option(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
choice(
|
||||
&[
|
||||
option_cacert,
|
||||
option_cert,
|
||||
option_key,
|
||||
option_compressed,
|
||||
option_insecure,
|
||||
option_follow_location,
|
||||
option_max_redirect,
|
||||
option_path_as_is,
|
||||
option_proxy,
|
||||
option_resolve,
|
||||
option_retry,
|
||||
option_retry_interval,
|
||||
option_variable,
|
||||
option_verbose,
|
||||
option_very_verbose,
|
||||
],
|
||||
reader,
|
||||
)
|
||||
}
|
||||
|
||||
fn option_cacert(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("cacert", reader)?;
|
||||
let pos = reader.state.pos.clone();
|
||||
let option = reader.read_while(|c| c.is_ascii_alphabetic() || *c == '-');
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
let f = filename::parse(reader)?;
|
||||
let kind = match option.as_str() {
|
||||
"cacert" => option_cacert(reader)?,
|
||||
"cert" => option_cert(reader)?,
|
||||
"compressed" => option_compressed(reader)?,
|
||||
"key" => option_key(reader)?,
|
||||
"insecure" => option_insecure(reader)?,
|
||||
"location" => option_follow_location(reader)?,
|
||||
"max-redirs" => option_max_redirect(reader)?,
|
||||
"path-as-is" => option_path_as_is(reader)?,
|
||||
"proxy" => option_proxy(reader)?,
|
||||
"resolve" => option_resolve(reader)?,
|
||||
"retry" => option_retry(reader)?,
|
||||
"retry-interval" => option_retry_interval(reader)?,
|
||||
"variable" => option_variable(reader)?,
|
||||
"verbose" => option_verbose(reader)?,
|
||||
"very-verbose" => option_very_verbose(reader)?,
|
||||
_ => {
|
||||
return Err(Error {
|
||||
pos,
|
||||
recoverable: true,
|
||||
inner: ParseError::InvalidOption,
|
||||
});
|
||||
}
|
||||
};
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
let option = CaCertificateOption {
|
||||
Ok(EntryOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
filename: f,
|
||||
kind,
|
||||
line_terminator0,
|
||||
};
|
||||
|
||||
Ok(EntryOption::CaCertificate(option))
|
||||
})
|
||||
}
|
||||
|
||||
fn option_cert(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("cert", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
let f = filename::parse(reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
let option = ClientCertOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
filename: f,
|
||||
line_terminator0,
|
||||
};
|
||||
|
||||
Ok(EntryOption::ClientCert(option))
|
||||
fn option_cacert(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = filename::parse(reader)?;
|
||||
Ok(OptionKind::CaCertificate(value))
|
||||
}
|
||||
|
||||
fn option_key(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("key", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
let f = filename::parse(reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
let option = ClientKeyOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
filename: f,
|
||||
line_terminator0,
|
||||
};
|
||||
|
||||
Ok(EntryOption::ClientKey(option))
|
||||
fn option_cert(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = filename::parse(reader)?;
|
||||
Ok(OptionKind::ClientCert(value))
|
||||
}
|
||||
|
||||
fn option_compressed(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("compressed", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
fn option_key(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = filename::parse(reader)?;
|
||||
Ok(OptionKind::ClientKey(value))
|
||||
}
|
||||
|
||||
fn option_compressed(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = nonrecover(boolean, reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
let option = CompressedOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
|
||||
Ok(EntryOption::Compressed(option))
|
||||
Ok(OptionKind::Compressed(value))
|
||||
}
|
||||
|
||||
fn option_insecure(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("insecure", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
fn option_insecure(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = nonrecover(boolean, reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
let option = InsecureOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
|
||||
Ok(EntryOption::Insecure(option))
|
||||
Ok(OptionKind::Insecure(value))
|
||||
}
|
||||
|
||||
fn option_follow_location(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("location", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
fn option_follow_location(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = nonrecover(boolean, reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
let option = FollowLocationOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
|
||||
Ok(EntryOption::FollowLocation(option))
|
||||
Ok(OptionKind::FollowLocation(value))
|
||||
}
|
||||
|
||||
fn option_max_redirect(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("max-redirs", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
fn option_max_redirect(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = nonrecover(natural, reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
// FIXME: try to not unwrap redirect value
|
||||
// and returns an error if not possible
|
||||
let option = MaxRedirectOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value: usize::try_from(value).unwrap(),
|
||||
line_terminator0,
|
||||
};
|
||||
|
||||
Ok(EntryOption::MaxRedirect(option))
|
||||
let value = usize::try_from(value).unwrap();
|
||||
Ok(OptionKind::MaxRedirect(value))
|
||||
}
|
||||
|
||||
fn option_path_as_is(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("path-as-is", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
fn option_path_as_is(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = nonrecover(boolean, reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
let option = PathAsIsOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
|
||||
Ok(EntryOption::PathAsIs(option))
|
||||
Ok(OptionKind::PathAsIs(value))
|
||||
}
|
||||
|
||||
fn option_proxy(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("proxy", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
fn option_proxy(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = proxy(reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
let option = ProxyOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
Ok(EntryOption::Proxy(option))
|
||||
Ok(OptionKind::Proxy(value))
|
||||
}
|
||||
|
||||
fn option_resolve(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = resolve(reader)?;
|
||||
Ok(OptionKind::Resolve(value))
|
||||
}
|
||||
|
||||
fn option_retry(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = retry(reader)?;
|
||||
Ok(OptionKind::Retry(value))
|
||||
}
|
||||
|
||||
fn option_retry_interval(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = nonrecover(natural, reader)?;
|
||||
Ok(OptionKind::RetryInterval(value))
|
||||
}
|
||||
|
||||
fn option_variable(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = variable_definition(reader)?;
|
||||
Ok(OptionKind::Variable(value))
|
||||
}
|
||||
|
||||
fn option_verbose(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = nonrecover(boolean, reader)?;
|
||||
Ok(OptionKind::Verbose(value))
|
||||
}
|
||||
|
||||
fn option_very_verbose(reader: &mut Reader) -> ParseResult<'static, OptionKind> {
|
||||
let value = nonrecover(boolean, reader)?;
|
||||
Ok(OptionKind::VeryVerbose(value))
|
||||
}
|
||||
|
||||
fn proxy(reader: &mut Reader) -> ParseResult<'static, String> {
|
||||
@ -590,26 +491,6 @@ fn proxy(reader: &mut Reader) -> ParseResult<'static, String> {
|
||||
Ok(name)
|
||||
}
|
||||
|
||||
fn option_resolve(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("resolve", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
let value = resolve(reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
let option = ResolveOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
Ok(EntryOption::Resolve(option))
|
||||
}
|
||||
|
||||
fn resolve(reader: &mut Reader) -> ParseResult<'static, String> {
|
||||
let start = reader.state.clone();
|
||||
let name = reader.read_while(|c| c.is_alphanumeric() || *c == ':' || *c == '.');
|
||||
@ -634,26 +515,6 @@ fn resolve(reader: &mut Reader) -> ParseResult<'static, String> {
|
||||
Ok(name)
|
||||
}
|
||||
|
||||
fn option_retry(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("retry", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
let value = retry(reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
let option = RetryOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
Ok(EntryOption::Retry(option))
|
||||
}
|
||||
|
||||
fn retry(reader: &mut Reader) -> ParseResult<Retry> {
|
||||
let pos = reader.state.pos.clone();
|
||||
let value = nonrecover(integer, reader)?;
|
||||
@ -673,47 +534,6 @@ fn retry(reader: &mut Reader) -> ParseResult<Retry> {
|
||||
})
|
||||
}
|
||||
}
|
||||
fn option_retry_interval(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("retry-interval", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
let value = nonrecover(natural, reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
let option = RetryIntervalOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
Ok(EntryOption::RetryInterval(option))
|
||||
}
|
||||
|
||||
fn option_variable(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("variable", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
let value = variable_definition(reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
let option = VariableOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
Ok(EntryOption::Variable(option))
|
||||
}
|
||||
|
||||
fn variable_definition(reader: &mut Reader) -> ParseResult<'static, VariableDefinition> {
|
||||
let name = variable_name(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
@ -782,50 +602,6 @@ fn variable_value(reader: &mut Reader) -> ParseResult<'static, VariableValue> {
|
||||
})
|
||||
}
|
||||
|
||||
fn option_verbose(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("verbose", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
let value = nonrecover(boolean, reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
let option = VerboseOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
|
||||
Ok(EntryOption::Verbose(option))
|
||||
}
|
||||
|
||||
fn option_very_verbose(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("very-verbose", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
let value = nonrecover(boolean, reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
let option = VeryVerboseOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
|
||||
Ok(EntryOption::VeryVerbose(option))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@ -980,10 +756,10 @@ mod tests {
|
||||
#[test]
|
||||
fn test_option_insecure() {
|
||||
let mut reader = Reader::new("insecure: true");
|
||||
let option = option_insecure(&mut reader).unwrap();
|
||||
let option = option(&mut reader).unwrap();
|
||||
assert_eq!(
|
||||
option,
|
||||
EntryOption::Insecure(InsecureOption {
|
||||
EntryOption {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
@ -1012,7 +788,7 @@ mod tests {
|
||||
},
|
||||
},
|
||||
},
|
||||
value: true,
|
||||
kind: OptionKind::Insecure(true),
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
@ -1042,24 +818,24 @@ mod tests {
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_option_insecure_error() {
|
||||
let mut reader = Reader::new("insecure: error");
|
||||
let error = option_insecure(&mut reader).err().unwrap();
|
||||
let error = option(&mut reader).err().unwrap();
|
||||
assert!(!error.recoverable)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_option_cacert() {
|
||||
let mut reader = Reader::new("cacert: /home/foo/cert.pem");
|
||||
let option = option_cacert(&mut reader).unwrap();
|
||||
let option = option(&mut reader).unwrap();
|
||||
assert_eq!(
|
||||
option,
|
||||
EntryOption::CaCertificate(CaCertificateOption {
|
||||
EntryOption {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
@ -1082,7 +858,7 @@ mod tests {
|
||||
end: Pos { line: 1, column: 9 },
|
||||
},
|
||||
},
|
||||
filename: Filename {
|
||||
kind: OptionKind::CaCertificate(Filename {
|
||||
value: "/home/foo/cert.pem".to_string(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos { line: 1, column: 9 },
|
||||
@ -1091,7 +867,7 @@ mod tests {
|
||||
column: 27,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
@ -1121,14 +897,14 @@ mod tests {
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_option_cacert_error() {
|
||||
let mut reader = Reader::new("cacert: ###");
|
||||
let error = option_cacert(&mut reader).err().unwrap();
|
||||
let error = option(&mut reader).err().unwrap();
|
||||
assert!(!error.recoverable)
|
||||
}
|
||||
|
||||
|
@ -271,87 +271,35 @@ impl ToJson for Cookie {
|
||||
|
||||
impl ToJson for EntryOption {
|
||||
fn to_json(&self) -> JValue {
|
||||
let attributes = match self {
|
||||
EntryOption::CaCertificate(value) => [
|
||||
("name".to_string(), JValue::String("cacert".to_string())),
|
||||
(
|
||||
"value".to_string(),
|
||||
JValue::String(value.filename.value.clone()),
|
||||
),
|
||||
],
|
||||
EntryOption::ClientCert(value) => [
|
||||
("name".to_string(), JValue::String("cert".to_string())),
|
||||
(
|
||||
"value".to_string(),
|
||||
JValue::String(value.filename.value.clone()),
|
||||
),
|
||||
],
|
||||
EntryOption::ClientKey(value) => [
|
||||
("name".to_string(), JValue::String("key".to_string())),
|
||||
(
|
||||
"value".to_string(),
|
||||
JValue::String(value.filename.value.clone()),
|
||||
),
|
||||
],
|
||||
EntryOption::Compressed(value) => [
|
||||
("name".to_string(), JValue::String("compressed".to_string())),
|
||||
("value".to_string(), JValue::Boolean(value.value)),
|
||||
],
|
||||
EntryOption::Insecure(value) => [
|
||||
("name".to_string(), JValue::String("insecure".to_string())),
|
||||
("value".to_string(), JValue::Boolean(value.value)),
|
||||
],
|
||||
EntryOption::FollowLocation(value) => [
|
||||
("name".to_string(), JValue::String("location".to_string())),
|
||||
("value".to_string(), JValue::Boolean(value.value)),
|
||||
],
|
||||
EntryOption::MaxRedirect(value) => [
|
||||
("name".to_string(), JValue::String("max-redirs".to_string())),
|
||||
("value".to_string(), JValue::Number(value.value.to_string())),
|
||||
],
|
||||
EntryOption::PathAsIs(value) => [
|
||||
("name".to_string(), JValue::String("path-as-is".to_string())),
|
||||
("value".to_string(), JValue::Boolean(value.value)),
|
||||
],
|
||||
EntryOption::Proxy(value) => [
|
||||
("name".to_string(), JValue::String("proxy".to_string())),
|
||||
("value".to_string(), JValue::String(value.value.clone())),
|
||||
],
|
||||
EntryOption::Resolve(value) => [
|
||||
("name".to_string(), JValue::String("resolve".to_string())),
|
||||
("value".to_string(), JValue::Number(value.value.to_string())),
|
||||
],
|
||||
EntryOption::Retry(value) => [
|
||||
("name".to_string(), JValue::String("retry".to_string())),
|
||||
("value".to_string(), JValue::Number(value.value.to_string())),
|
||||
],
|
||||
EntryOption::RetryInterval(value) => [
|
||||
(
|
||||
"name".to_string(),
|
||||
JValue::String("retry-interval".to_string()),
|
||||
),
|
||||
("value".to_string(), JValue::Number(value.value.to_string())),
|
||||
],
|
||||
EntryOption::Variable(value) => [
|
||||
("name".to_string(), JValue::String("variable".to_string())),
|
||||
(
|
||||
"value".to_string(),
|
||||
JValue::String(format!("{}={}", value.value.name, value.value.value)),
|
||||
),
|
||||
],
|
||||
EntryOption::Verbose(value) => [
|
||||
("name".to_string(), JValue::String("verbose".to_string())),
|
||||
("value".to_string(), JValue::Boolean(value.value)),
|
||||
],
|
||||
EntryOption::VeryVerbose(value) => [
|
||||
(
|
||||
"name".to_string(),
|
||||
JValue::String("very-verbose".to_string()),
|
||||
),
|
||||
("value".to_string(), JValue::Boolean(value.value)),
|
||||
],
|
||||
let mut attributes = vec![];
|
||||
|
||||
let name = "name".to_string();
|
||||
let value = JValue::String(self.kind.name().to_string());
|
||||
attributes.push((name, value));
|
||||
|
||||
let name = "value".to_string();
|
||||
let value = match &self.kind {
|
||||
OptionKind::CaCertificate(filename) => JValue::String(filename.value.clone()),
|
||||
OptionKind::ClientCert(filename) => JValue::String(filename.value.clone()),
|
||||
OptionKind::ClientKey(filename) => JValue::String(filename.value.clone()),
|
||||
OptionKind::Compressed(value) => JValue::Boolean(*value),
|
||||
OptionKind::Insecure(value) => JValue::Boolean(*value),
|
||||
OptionKind::FollowLocation(value) => JValue::Boolean(*value),
|
||||
OptionKind::MaxRedirect(value) => JValue::Number(value.to_string()),
|
||||
OptionKind::PathAsIs(value) => JValue::Boolean(*value),
|
||||
OptionKind::Proxy(value) => JValue::String(value.clone()),
|
||||
OptionKind::Resolve(value) => JValue::String(value.clone()),
|
||||
OptionKind::Retry(value) => JValue::Number(value.to_string()),
|
||||
OptionKind::RetryInterval(value) => JValue::Number(value.to_string()),
|
||||
OptionKind::Variable(value) => {
|
||||
JValue::String(format!("{}={}", value.name, value.value))
|
||||
}
|
||||
OptionKind::Verbose(value) => JValue::Boolean(*value),
|
||||
OptionKind::VeryVerbose(value) => JValue::Boolean(*value),
|
||||
};
|
||||
JValue::Object(attributes.to_vec())
|
||||
attributes.push((name, value));
|
||||
|
||||
JValue::Object(attributes)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -855,262 +855,49 @@ impl Tokenizable for JsonObjectElement {
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for EntryOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String(self.kind.name().to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.append(&mut self.kind.tokenize());
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for OptionKind {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
match self {
|
||||
EntryOption::CaCertificate(option) => option.tokenize(),
|
||||
EntryOption::ClientCert(option) => option.tokenize(),
|
||||
EntryOption::ClientKey(option) => option.tokenize(),
|
||||
EntryOption::Compressed(option) => option.tokenize(),
|
||||
EntryOption::Insecure(option) => option.tokenize(),
|
||||
EntryOption::FollowLocation(option) => option.tokenize(),
|
||||
EntryOption::MaxRedirect(option) => option.tokenize(),
|
||||
EntryOption::PathAsIs(option) => option.tokenize(),
|
||||
EntryOption::Proxy(option) => option.tokenize(),
|
||||
EntryOption::Resolve(option) => option.tokenize(),
|
||||
EntryOption::Retry(option) => option.tokenize(),
|
||||
EntryOption::RetryInterval(option) => option.tokenize(),
|
||||
EntryOption::Variable(option) => option.tokenize(),
|
||||
EntryOption::Verbose(option) => option.tokenize(),
|
||||
EntryOption::VeryVerbose(option) => option.tokenize(),
|
||||
OptionKind::CaCertificate(filename) => filename.tokenize(),
|
||||
OptionKind::ClientCert(filename) => filename.tokenize(),
|
||||
OptionKind::ClientKey(filename) => filename.tokenize(),
|
||||
OptionKind::Compressed(value) => vec![Token::Boolean(value.to_string())],
|
||||
OptionKind::Insecure(value) => vec![Token::Boolean(value.to_string())],
|
||||
OptionKind::FollowLocation(value) => vec![Token::Boolean(value.to_string())],
|
||||
OptionKind::MaxRedirect(value) => vec![Token::Number(value.to_string())],
|
||||
OptionKind::PathAsIs(value) => vec![Token::Boolean(value.to_string())],
|
||||
OptionKind::Proxy(value) => vec![Token::FilterType(value.clone())],
|
||||
OptionKind::Resolve(value) => vec![Token::FilterType(value.clone())],
|
||||
OptionKind::Retry(value) => value.tokenize(),
|
||||
OptionKind::RetryInterval(value) => vec![Token::Number(value.to_string())],
|
||||
OptionKind::Variable(value) => value.tokenize(),
|
||||
OptionKind::Verbose(value) => vec![Token::Boolean(value.to_string())],
|
||||
OptionKind::VeryVerbose(value) => vec![Token::Boolean(value.to_string())],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for CaCertificateOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("cacert".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.append(&mut self.filename.tokenize());
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for ClientCertOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("cert".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.append(&mut self.filename.tokenize());
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for ClientKeyOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("key".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.append(&mut self.filename.tokenize());
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for CompressedOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("compressed".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.push(Token::Boolean(self.value.to_string()));
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for InsecureOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("insecure".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.push(Token::Boolean(self.value.to_string()));
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for FollowLocationOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("location".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.push(Token::Boolean(self.value.to_string()));
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for MaxRedirectOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("max-redirs".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.push(Token::Number(self.value.to_string()));
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for PathAsIsOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("path-as-is".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.push(Token::Boolean(self.value.to_string()));
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for ProxyOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("proxy".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.push(Token::String(self.value.clone()));
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for ResolveOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("resolve".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.push(Token::String(self.value.clone()));
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for RetryOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
if !matches!(self.value, Retry::None) {
|
||||
tokens.push(Token::String("retry".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.append(&mut self.value.tokenize());
|
||||
}
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for Retry {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
match self {
|
||||
@ -1121,48 +908,6 @@ impl Tokenizable for Retry {
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for RetryIntervalOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("retry-interval".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.push(Token::Number(self.value.to_string()));
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for VariableOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("variable".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.append(&mut self.value.tokenize());
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for VariableDefinition {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![Token::String(self.name.clone())];
|
||||
@ -1186,48 +931,6 @@ impl Tokenizable for VariableValue {
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for VerboseOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("verbose".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.push(Token::Boolean(self.value.to_string()));
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for VeryVerboseOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("very-verbose".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.push(Token::Boolean(self.value.to_string()));
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for Filter {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
match self.value.clone() {
|
||||
|
Loading…
Reference in New Issue
Block a user