Skip to content

Commit 2585049

Browse files
committed
#447: Add more options to 'wrap' command
1 parent 76085b9 commit 2585049

File tree

3 files changed

+80
-17
lines changed

3 files changed

+80
-17
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
but don't have a good way to check the registry keys directly.
2222
* CLI: The `find` command now supports `--fuzzy` and `--multiple` options.
2323
This is also available for the `api` command's `findTitle` request.
24+
* CLI: The `wrap` command now supports several options from the `backup` command:
25+
`--path`,
26+
`--format`,
27+
`--compression`,
28+
`--compression-level`,
29+
`--full-limit`,
30+
`--differential-limit`,
31+
`--cloud-sync`,
32+
`--no-cloud-sync`.
2433
* Changed:
2534
* When the game list is filtered,
2635
the summary line (e.g., "1 of 10 games") now reflects the filtered totals.

src/cli.rs

+25-17
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,14 @@ pub fn run(sub: Subcommand, no_manifest_update: bool, try_manifest_update: bool)
871871
name_source,
872872
force,
873873
gui,
874+
path,
875+
format,
876+
compression,
877+
compression_level,
878+
full_limit,
879+
differential_limit,
880+
cloud_sync,
881+
no_cloud_sync,
874882
commands,
875883
} => {
876884
let manifest = load_manifest(&config, &mut cache, no_manifest_update, try_manifest_update)?;
@@ -959,20 +967,20 @@ pub fn run(sub: Subcommand, no_manifest_update: bool, try_manifest_update: bool)
959967
Subcommand::Restore {
960968
games: vec![game_name.clone()],
961969
force: true,
962-
preview: Default::default(),
963-
path: Default::default(),
970+
preview,
971+
path: path.clone(),
964972
api: Default::default(),
965973
gui: Default::default(),
966974
sort: Default::default(),
967975
backup: Default::default(),
968-
cloud_sync: Default::default(),
969-
no_cloud_sync: Default::default(),
976+
cloud_sync,
977+
no_cloud_sync,
970978
dump_registry: Default::default(),
971979
},
972980
no_manifest_update,
973981
try_manifest_update,
974982
) {
975-
log::error!("WRAP::restore: failed for game {:?} with: {:?}", wrap_game_info, err);
983+
log::error!("Wrap failed to restore game {:?} with: {:?}", wrap_game_info, err);
976984
ui::alert_with_error(gui, force, &TRANSLATOR.restore_one_game_failed(game_name), &err)?;
977985
return Err(err);
978986
}
@@ -983,10 +991,10 @@ pub fn run(sub: Subcommand, no_manifest_update: bool, try_manifest_update: bool)
983991
let result = Command::new(&commands[0]).args(&commands[1..]).status();
984992
match result {
985993
Ok(status) => {
986-
log::debug!("WRAP::execute: Game command executed, returning status: {:#?}", status);
994+
log::debug!("Wrapped game command executed, returning status: {:#?}", status);
987995
}
988996
Err(err) => {
989-
log::error!("WRAP::execute: Game command execution failed with: {:#?}", err);
997+
log::error!("Wrapped game command execution failed with: {:#?}", err);
990998
ui::alert_with_raw_error(gui, force, &TRANSLATOR.game_did_not_launch(), &err.to_string())?;
991999
return Err(Error::GameDidNotLaunch { why: err.to_string() });
9921000
}
@@ -1006,25 +1014,25 @@ pub fn run(sub: Subcommand, no_manifest_update: bool, try_manifest_update: bool)
10061014
Subcommand::Backup {
10071015
games: vec![game_name.clone()],
10081016
force: true,
1009-
preview: Default::default(),
1010-
path: Default::default(),
1017+
preview,
1018+
path,
10111019
wine_prefix: Default::default(),
10121020
api: Default::default(),
10131021
gui: Default::default(),
10141022
sort: Default::default(),
1015-
format: Default::default(),
1016-
compression: Default::default(),
1017-
compression_level: Default::default(),
1018-
full_limit: Default::default(),
1019-
differential_limit: Default::default(),
1020-
cloud_sync: Default::default(),
1021-
no_cloud_sync: Default::default(),
1023+
format,
1024+
compression,
1025+
compression_level,
1026+
full_limit,
1027+
differential_limit,
1028+
cloud_sync,
1029+
no_cloud_sync,
10221030
dump_registry: Default::default(),
10231031
},
10241032
no_manifest_update,
10251033
try_manifest_update,
10261034
) {
1027-
log::error!("WRAP::backup: failed with: {:#?}", err);
1035+
log::error!("Wrap failed to back up with: {:#?}", err);
10281036
ui::alert_with_error(gui, force, &TRANSLATOR.back_up_one_game_failed(game_name), &err)?;
10291037
return Err(err);
10301038
}

src/cli/parse.rs

+46
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,52 @@ pub enum Subcommand {
400400
#[clap(long)]
401401
gui: bool,
402402

403+
/// Directory in which to find/store backups.
404+
/// It will be created if it does not already exist.
405+
/// When not specified, this defers to the config file.
406+
#[clap(long, value_parser = parse_strict_path)]
407+
path: Option<StrictPath>,
408+
409+
/// Format in which to store new backups.
410+
/// When not specified, this defers to the config file.
411+
#[clap(long, value_parser = possible_values!(BackupFormat, ALL_NAMES))]
412+
format: Option<BackupFormat>,
413+
414+
/// Compression method to use for new zip backups.
415+
/// When not specified, this defers to the config file.
416+
#[clap(long, value_parser = possible_values!(ZipCompression, ALL_NAMES))]
417+
compression: Option<ZipCompression>,
418+
419+
/// Compression level to use for new zip backups.
420+
/// When not specified, this defers to the config file.
421+
/// Valid ranges: 1 to 9 for deflate/bzip2, -7 to 22 for zstd.
422+
#[clap(long, allow_hyphen_values(true))]
423+
compression_level: Option<i32>,
424+
425+
/// Maximum number of full backups to retain per game.
426+
/// Must be between 1 and 255 (inclusive).
427+
/// When not specified, this defers to the config file.
428+
#[clap(long)]
429+
full_limit: Option<u8>,
430+
431+
/// Maximum number of differential backups to retain per full backup.
432+
/// Must be between 0 and 255 (inclusive).
433+
/// When not specified, this defers to the config file.
434+
#[clap(long)]
435+
differential_limit: Option<u8>,
436+
437+
/// Upload any changes to the cloud when the backup is complete.
438+
/// If the local and cloud backups are not in sync to begin with,
439+
/// then nothing will be uploaded.
440+
/// When not specified, this defers to the config file.
441+
#[clap(long)]
442+
cloud_sync: bool,
443+
444+
/// Don't perform any cloud checks or synchronization.
445+
/// When not specified, this defers to the config file.
446+
#[clap(long, conflicts_with("cloud_sync"))]
447+
no_cloud_sync: bool,
448+
403449
/// Commands to launch the game.
404450
/// Use `--` first to separate these from the `wrap` options;
405451
/// e.g., `ludusavi wrap --name foo -- foo.exe --windowed`.

0 commit comments

Comments
 (0)