mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-09-11 05:35:53 +03:00
Add very-verbose entry option.
This commit is contained in:
parent
633500ebbd
commit
b08de3a19b
@ -119,7 +119,7 @@ assert:
|
||||
|
||||
option:
|
||||
lt*
|
||||
(insecure-option | ca-certificate-option | verbose-option)
|
||||
(insecure-option | ca-certificate-option | verbose-option | very-verbose-option)
|
||||
|
||||
insecure-option: "insecure" ":" boolean lt
|
||||
|
||||
@ -127,6 +127,7 @@ ca-certificate-option: "cacert" ":" filename lt
|
||||
|
||||
verbose-option: "verbose" ":" boolean lt
|
||||
|
||||
very-verbose-option: "verbose" ":" boolean lt
|
||||
|
||||
# Query
|
||||
|
||||
|
@ -26,3 +26,35 @@
|
||||
< Date: ~~~, ~~ ~~~ ~~~~ ~~:~~:~~ GMT
|
||||
<
|
||||
*
|
||||
* ------------------------------------------------------------------------------
|
||||
* Executing entry 4
|
||||
*
|
||||
* Entry options:
|
||||
* very-verbose: true
|
||||
*
|
||||
* Cookie store:
|
||||
*
|
||||
* Request:
|
||||
* GET http://localhost:8000/hello
|
||||
*
|
||||
* Request can be run with the following curl command:
|
||||
* curl 'http://localhost:8000/hello'
|
||||
*
|
||||
> GET /hello HTTP/1.1
|
||||
> Host: localhost:8000
|
||||
> Accept: */*
|
||||
> User-Agent: hurl/~~~
|
||||
>
|
||||
* Request body:
|
||||
*
|
||||
* Response:
|
||||
*
|
||||
< HTTP/1.0 200 OK
|
||||
< Content-Type: text/html; charset=utf-8
|
||||
< Content-Length: 12
|
||||
< Server: Flask Server
|
||||
< Date: ~~~, ~~ ~~~ ~~~~ ~~:~~:~~ GMT
|
||||
<
|
||||
* Response body:
|
||||
* Hello World!
|
||||
*
|
||||
|
@ -7,4 +7,9 @@
|
||||
<span class="line"><span class="version">HTTP/*</span> <span class="number">200</span></span>
|
||||
<span class="raw"><span class="line">```Hello World!```</span></span>
|
||||
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/hello</span></span></span></span></code></pre>
|
||||
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/hello</span></span>
|
||||
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/hello</span></span>
|
||||
<span class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">very-verbose</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span></span></code></pre>
|
@ -7,4 +7,8 @@ verbose: true
|
||||
HTTP/* 200
|
||||
```Hello World!```
|
||||
|
||||
GET http://localhost:8000/hello
|
||||
GET http://localhost:8000/hello
|
||||
|
||||
GET http://localhost:8000/hello
|
||||
[Options]
|
||||
very-verbose: true
|
||||
|
@ -1 +1 @@
|
||||
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello"}},{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"raw-string","value":"Hello World!"}}},{"request":{"method":"GET","url":"http://localhost:8000/hello"}}]}
|
||||
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello"}},{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"raw-string","value":"Hello World!"}}},{"request":{"method":"GET","url":"http://localhost:8000/hello"}},{"request":{"method":"GET","url":"http://localhost:8000/hello"}}]}
|
@ -259,6 +259,15 @@ pub fn get_entry_options(
|
||||
};
|
||||
logger.debug(format!("verbose: {}", option.value).as_str());
|
||||
}
|
||||
|
||||
EntryOption::VeryVerbose(option) => {
|
||||
client_options.verbosity = if option.value {
|
||||
Some(Verbosity::VeryVerbose)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
logger.debug(format!("very-verbose: {}", option.value).as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -282,12 +291,22 @@ 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 {
|
||||
if let EntryOption::Verbose(option) = option {
|
||||
verbosity = if option.value {
|
||||
Some(Verbosity::Verbose)
|
||||
} else {
|
||||
None
|
||||
match option {
|
||||
EntryOption::Verbose(option) => {
|
||||
verbosity = if option.value {
|
||||
Some(Verbosity::Verbose)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
EntryOption::VeryVerbose(option) => {
|
||||
verbosity = if option.value {
|
||||
Some(Verbosity::VeryVerbose)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -670,6 +670,7 @@ pub enum EntryOption {
|
||||
Insecure(InsecureOption),
|
||||
CaCertificate(CaCertificateOption),
|
||||
Verbose(VerboseOption),
|
||||
VeryVerbose(VeryVerboseOption),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
@ -701,3 +702,13 @@ pub struct VerboseOption {
|
||||
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,
|
||||
}
|
||||
|
@ -235,6 +235,7 @@ impl Htmlable for EntryOption {
|
||||
EntryOption::Insecure(option) => option.to_html(),
|
||||
EntryOption::CaCertificate(option) => option.to_html(),
|
||||
EntryOption::Verbose(option) => option.to_html(),
|
||||
EntryOption::VeryVerbose(option) => option.to_html(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -290,6 +291,23 @@ impl Htmlable for VerboseOption {
|
||||
}
|
||||
}
|
||||
|
||||
impl Htmlable for VeryVerboseOption {
|
||||
fn to_html(&self) -> String {
|
||||
let mut buffer = String::from("");
|
||||
add_line_terminators(&mut buffer, self.line_terminators.clone());
|
||||
buffer.push_str("<span class=\"line\">");
|
||||
buffer.push_str(self.space0.to_html().as_str());
|
||||
buffer.push_str("<span class=\"string\">very-verbose</span>");
|
||||
buffer.push_str(self.space1.to_html().as_str());
|
||||
buffer.push_str("<span>:</span>");
|
||||
buffer.push_str(self.space2.to_html().as_str());
|
||||
buffer.push_str(format!("<span class=\"boolean\">{}</span>", self.value).as_str());
|
||||
buffer.push_str("</span>");
|
||||
buffer.push_str(self.line_terminator0.to_html().as_str());
|
||||
buffer
|
||||
}
|
||||
}
|
||||
|
||||
impl Htmlable for MultipartParam {
|
||||
fn to_html(&self) -> String {
|
||||
match self {
|
||||
|
@ -342,7 +342,15 @@ fn assert(reader: &mut Reader) -> ParseResult<'static, Assert> {
|
||||
}
|
||||
|
||||
fn option(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
choice(vec![option_insecure, option_cacert, option_verbose], reader)
|
||||
choice(
|
||||
vec![
|
||||
option_insecure,
|
||||
option_cacert,
|
||||
option_verbose,
|
||||
option_very_verbose,
|
||||
],
|
||||
reader,
|
||||
)
|
||||
}
|
||||
|
||||
fn option_insecure(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
@ -411,6 +419,28 @@ fn option_verbose(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
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::*;
|
||||
|
@ -821,6 +821,7 @@ impl Tokenizable for EntryOption {
|
||||
EntryOption::Insecure(option) => option.tokenize(),
|
||||
EntryOption::CaCertificate(option) => option.tokenize(),
|
||||
EntryOption::Verbose(option) => option.tokenize(),
|
||||
EntryOption::VeryVerbose(option) => option.tokenize(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -887,3 +888,24 @@ impl Tokenizable for VerboseOption {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user