mirror of
https://github.com/nushell/nushell.git
synced 2024-11-21 16:03:19 +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,
|
||||
) -> Result<Request, ShellError> {
|
||||
if let Some(timeout) = timeout {
|
||||
let val = timeout.as_i64()?;
|
||||
let val = timeout.as_duration()?;
|
||||
if val.is_negative() || val < 1 {
|
||||
return Err(ShellError::TypeMismatch {
|
||||
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)
|
||||
|
@ -43,8 +43,8 @@ impl Command for SubCommand {
|
||||
)
|
||||
.named(
|
||||
"max-time",
|
||||
SyntaxShape::Int,
|
||||
"timeout period in seconds",
|
||||
SyntaxShape::Duration,
|
||||
"max duration before timeout occurs",
|
||||
Some('m'),
|
||||
)
|
||||
.named(
|
||||
|
@ -38,8 +38,8 @@ impl Command for SubCommand {
|
||||
)
|
||||
.named(
|
||||
"max-time",
|
||||
SyntaxShape::Int,
|
||||
"timeout period in seconds",
|
||||
SyntaxShape::Duration,
|
||||
"max duration before timeout occurs",
|
||||
Some('m'),
|
||||
)
|
||||
.named(
|
||||
|
@ -38,8 +38,8 @@ impl Command for SubCommand {
|
||||
)
|
||||
.named(
|
||||
"max-time",
|
||||
SyntaxShape::Int,
|
||||
"timeout period in seconds",
|
||||
SyntaxShape::Duration,
|
||||
"max duration before timeout occurs",
|
||||
Some('m'),
|
||||
)
|
||||
.named(
|
||||
|
@ -37,8 +37,8 @@ impl Command for SubCommand {
|
||||
)
|
||||
.named(
|
||||
"max-time",
|
||||
SyntaxShape::Int,
|
||||
"timeout period in seconds",
|
||||
SyntaxShape::Duration,
|
||||
"max duration before timeout occurs",
|
||||
Some('m'),
|
||||
)
|
||||
.named(
|
||||
|
@ -39,8 +39,8 @@ impl Command for SubCommand {
|
||||
)
|
||||
.named(
|
||||
"max-time",
|
||||
SyntaxShape::Int,
|
||||
"timeout period in seconds",
|
||||
SyntaxShape::Duration,
|
||||
"max duration before timeout occurs",
|
||||
Some('m'),
|
||||
)
|
||||
.named(
|
||||
|
@ -39,8 +39,8 @@ impl Command for SubCommand {
|
||||
)
|
||||
.named(
|
||||
"max-time",
|
||||
SyntaxShape::Int,
|
||||
"timeout period in seconds",
|
||||
SyntaxShape::Duration,
|
||||
"max duration before timeout occurs",
|
||||
Some('m'),
|
||||
)
|
||||
.named(
|
||||
|
@ -39,8 +39,8 @@ impl Command for SubCommand {
|
||||
)
|
||||
.named(
|
||||
"max-time",
|
||||
SyntaxShape::Int,
|
||||
"timeout period in seconds",
|
||||
SyntaxShape::Duration,
|
||||
"max duration before timeout occurs",
|
||||
Some('m'),
|
||||
)
|
||||
.named(
|
||||
|
Loading…
Reference in New Issue
Block a user