Skip to content

Commit 02b7501

Browse files
committed
validate poll-interval
1 parent 9192f27 commit 02b7501

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/commands/logs/list.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ fn validate_max_rows(s: &str) -> Result<usize> {
2424
}
2525
}
2626

27+
/// Validate that poll-interval is a positive integer (> 0)
28+
fn validate_poll_interval(s: &str) -> Result<u64> {
29+
let value = s.parse()?;
30+
if value > 0 {
31+
Ok(value)
32+
} else {
33+
Err(anyhow::anyhow!("poll-interval must be a positive integer"))
34+
}
35+
}
36+
2737
/// Check if a project identifier is numeric (project ID) or string (project slug)
2838
fn is_numeric_project_id(project: &str) -> bool {
2939
!project.is_empty() && project.chars().all(|c| c.is_ascii_digit())
@@ -63,7 +73,8 @@ pub(super) struct ListLogsArgs {
6373
live: bool,
6474

6575
#[arg(long = "poll-interval", default_value = "2")]
66-
#[arg(help = "Poll interval in seconds. Only used when --live is specified.")]
76+
#[arg(value_parser = validate_poll_interval)]
77+
#[arg(help = "Poll interval in seconds (must be > 0). Only used when --live is specified.")]
6778
poll_interval: u64,
6879
}
6980

0 commit comments

Comments
 (0)