mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
Change --max-time arg for http commands to use Duration
type (#14237)
# Description Fixes #14222. The ability to set duration unit for `--max-time` when using the `http` command util. Signed-off-by: Alex Johnson <alex.kattathra.johnson@gmail.com>
This commit is contained in:
parent
a935e0720f
commit
d289c773d0
@ -525,7 +525,7 @@ pub fn request_set_timeout(
|
|||||||
mut request: Request,
|
mut request: Request,
|
||||||
) -> Result<Request, ShellError> {
|
) -> Result<Request, ShellError> {
|
||||||
if let Some(timeout) = timeout {
|
if let Some(timeout) = timeout {
|
||||||
let val = timeout.as_i64()?;
|
let val = timeout.as_duration()?;
|
||||||
if val.is_negative() || val < 1 {
|
if val.is_negative() || val < 1 {
|
||||||
return Err(ShellError::TypeMismatch {
|
return Err(ShellError::TypeMismatch {
|
||||||
err_message: "Timeout value must be an int and larger than 0".to_string(),
|
err_message: "Timeout value must be an int and larger than 0".to_string(),
|
||||||
@ -533,7 +533,7 @@ pub fn request_set_timeout(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
request = request.timeout(Duration::from_secs(val as u64));
|
request = request.timeout(Duration::from_nanos(val as u64));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(request)
|
Ok(request)
|
||||||
|
@ -43,8 +43,8 @@ impl Command for SubCommand {
|
|||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
"max-time",
|
"max-time",
|
||||||
SyntaxShape::Int,
|
SyntaxShape::Duration,
|
||||||
"timeout period in seconds",
|
"max duration before timeout occurs",
|
||||||
Some('m'),
|
Some('m'),
|
||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
|
@ -38,8 +38,8 @@ impl Command for SubCommand {
|
|||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
"max-time",
|
"max-time",
|
||||||
SyntaxShape::Int,
|
SyntaxShape::Duration,
|
||||||
"timeout period in seconds",
|
"max duration before timeout occurs",
|
||||||
Some('m'),
|
Some('m'),
|
||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
|
@ -38,8 +38,8 @@ impl Command for SubCommand {
|
|||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
"max-time",
|
"max-time",
|
||||||
SyntaxShape::Int,
|
SyntaxShape::Duration,
|
||||||
"timeout period in seconds",
|
"max duration before timeout occurs",
|
||||||
Some('m'),
|
Some('m'),
|
||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
|
@ -37,8 +37,8 @@ impl Command for SubCommand {
|
|||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
"max-time",
|
"max-time",
|
||||||
SyntaxShape::Int,
|
SyntaxShape::Duration,
|
||||||
"timeout period in seconds",
|
"max duration before timeout occurs",
|
||||||
Some('m'),
|
Some('m'),
|
||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
|
@ -39,8 +39,8 @@ impl Command for SubCommand {
|
|||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
"max-time",
|
"max-time",
|
||||||
SyntaxShape::Int,
|
SyntaxShape::Duration,
|
||||||
"timeout period in seconds",
|
"max duration before timeout occurs",
|
||||||
Some('m'),
|
Some('m'),
|
||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
|
@ -39,8 +39,8 @@ impl Command for SubCommand {
|
|||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
"max-time",
|
"max-time",
|
||||||
SyntaxShape::Int,
|
SyntaxShape::Duration,
|
||||||
"timeout period in seconds",
|
"max duration before timeout occurs",
|
||||||
Some('m'),
|
Some('m'),
|
||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
|
@ -39,8 +39,8 @@ impl Command for SubCommand {
|
|||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
"max-time",
|
"max-time",
|
||||||
SyntaxShape::Int,
|
SyntaxShape::Duration,
|
||||||
"timeout period in seconds",
|
"max duration before timeout occurs",
|
||||||
Some('m'),
|
Some('m'),
|
||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
|
Loading…
Reference in New Issue
Block a user