Skip to content

Commit

Permalink
add -e/--exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
mxve committed Nov 28, 2023
1 parent 4d3f84f commit 18295ff
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ or
- Restore backed up version
- ```--cdn-url```
- Override cdn url
- ```-e, --exclude "file|folder```
- Exclude file or folder from update
- Can be used multiple times
- Example: ```-e "games/t6mp.exe" -e "storage"```

### Exit codes
- 0 success
Expand Down
4 changes: 4 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ pub struct Args {
// get cdn version
#[clap(long)]
pub version_cdn: bool,

// Exclude remote dirs
#[clap(short, long)]
pub exclude: Vec<String>,
}

pub fn get() -> Args {
Expand Down
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ fn update(args: &args::Args, cdn_info: &CdnInfo, local_info: &CdnInfo) {
};

// iterate cdn files
for cdn_file in &cdn_info.files {
'cdn_iterator: for cdn_file in &cdn_info.files {
if !args.silent {
pb.set_message((cdn_file.name).to_string());
}
Expand All @@ -273,6 +273,17 @@ fn update(args: &args::Args, cdn_info: &CdnInfo, local_info: &CdnInfo) {
continue;
}

for exclude in &args.exclude {
if cdn_file.name.starts_with(exclude) {
if !args.quiet && !args.silent {
pb.println(format!("{}: {}", "Skipped".bright_blue(), &cdn_file.name));
};
stats.skipped += 1;
pb.inc(cdn_file.size as u64);
continue 'cdn_iterator;
}
}

let file_path = Path::join(install_dir, Path::new(&cdn_file.name));
let file_dir = file_path.parent().unwrap();

Expand Down

0 comments on commit 18295ff

Please sign in to comment.