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:
Alex Kattathra Johnson 2024-11-03 12:35:08 -06:00 committed by GitHub
parent a935e0720f
commit d289c773d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 16 additions and 16 deletions

View File

@ -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)

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(