Rudo2204 / rpl

Rudo's pack leecher. Download large sized package using small, affordable machines.
0 stars 1 forks source link

Add `--include` and `--exclude` options #7

Open abusenet opened 3 years ago

abusenet commented 3 years ago

Some times I just want to redownload 1 or 2 chunks. Using --skip works fine, but I have to monitor the progress to stop rpl downloading the next chunks.

Please add --include N and --exclude N options to let the user choose the chunks to download.

Rudo2204 commented 3 years ago

Idea for --include. --exclude maybe reverse this skip all the chunks from the function result.

use arrayvec::ArrayVec;
use std::collections::BTreeSet;

let s = "1,5,7-9";
let mut set = BTreeSet::new();
for e in s.split(',') {
    let a: ArrayVec<u64, 2> = e.split('-').map(|v| v.parse().unwrap()).collect();
    match *a {
        [a] => {
            set.insert(a);
        }
        [a, b] => {
            set.extend(a..=b);
        }
        _ => panic!()
    }    
}
set

Result is: {1,5,7,8,9}