Skip to content

Commit

Permalink
Allow human-readable messages on stderr in API mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed May 19, 2023
1 parent 3c77618 commit 80ce51f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
To ignore errors in the update, use the new `--try-manifest-update` global flag.
* CLI: The deprecated `--by-steam-id` option has been removed from the `backup`, `backups`, and `restore` commands.
You can use the `find` command to replicate this functionality.
* CLI: Using `--api` mode would silence some human-readable errors that would otherwise go on stderr.
Since the API output itself goes on stdout, there's no harm leaving the other messages on stderr,
so they are now allowed to print.
In the future, these messages may be integrated into the API output directly.
* GUI: If you try to close the program while an operation is ongoing,
Ludusavi will cancel the operation cleanly first before closing.
To skip the cleanup and force an immediate close (like in previous versions),
Expand Down
17 changes: 0 additions & 17 deletions src/cli/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,23 +326,6 @@ pub enum Subcommand {
},
}

impl Subcommand {
pub fn api(&self) -> bool {
match self {
Self::Backup { api, .. } => *api,
Self::Restore { api, .. } => *api,
Self::Backups { api, .. } => *api,
Self::Find { api, .. } => *api,
Self::Manifest { sub } => match sub {
ManifestSubcommand::Show { api } => *api,
ManifestSubcommand::Update { .. } => false,
},
Self::Complete { .. } => false,
Self::Cloud { .. } => false,
}
}
}

#[derive(clap::Subcommand, Clone, Debug, PartialEq, Eq)]
pub enum ManifestSubcommand {
/// Print the content of the manifest, including any custom entries.
Expand Down
5 changes: 1 addition & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,8 @@ fn main() {

log::debug!("Version: {}", *VERSION);

let api = sub.api();
if let Err(e) = cli::run(sub, args.no_manifest_update, args.try_manifest_update) {
if !api {
eprintln!("{}", TRANSLATOR.handle_error(&e));
}
eprintln!("{}", TRANSLATOR.handle_error(&e));
std::process::exit(1);
}
}
Expand Down

0 comments on commit 80ce51f

Please sign in to comment.