mirror of
https://github.com/YGGverse/pulsarss.git
synced 2026-03-31 17:15:29 +00:00
update limit argument data type
This commit is contained in:
parent
a22fa6449a
commit
f3045ad5a4
2 changed files with 4 additions and 4 deletions
|
|
@ -8,8 +8,8 @@ pub struct Argument {
|
|||
pub index: Option<String>,
|
||||
|
||||
/// Limit channel items (unlimited by default)
|
||||
#[arg(short, long, default_value_t = 0)]
|
||||
pub limit: usize,
|
||||
#[arg(short, long)]
|
||||
pub limit: Option<usize>,
|
||||
|
||||
/// Show output (`dw` by default)
|
||||
#[arg(short, long, default_value_t = String::from("dw"))]
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ fn crawl(argument: &Argument, output: &Output) -> Result<(), Box<dyn Error>> {
|
|||
.items()
|
||||
.iter()
|
||||
{
|
||||
if argument.limit > 0 && total >= argument.limit {
|
||||
if argument.limit.is_some_and(|limit| total >= limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ fn crawl(argument: &Argument, output: &Output) -> Result<(), Box<dyn Error>> {
|
|||
let mut files: Vec<_> = read_dir(&path)?.filter_map(Result::ok).collect();
|
||||
files.sort_by_key(|f| f.file_name());
|
||||
|
||||
let mut data = Vec::with_capacity(argument.limit);
|
||||
let mut data = Vec::with_capacity(argument.limit.unwrap_or_default());
|
||||
let mut index = File::create(&index_filename)?;
|
||||
let mut total = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue