feat: flag and config to skip notifications by jlucktay (#5)

* feat: flag and config to skip notifications

At the end of a run, topgrade normally sends a system notification.
This change adds a command-line flag and a config-file option to
disable this behaviour.

* fix: clippy issues

Also derive Eq where PartialEq is being derived.
https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq

Authored-by: James Lucktaylor <jlucktay+github@gmail.com>
Approved-by: Thomas Schönauer <t.schoenauer@hgs-wt.at>
This commit is contained in:
DottoDev
2022-10-10 20:21:20 +00:00
committed by GitHub
parent dc1c5d6490
commit 2d94eb974f
5 changed files with 30 additions and 9 deletions

View File

@@ -272,6 +272,7 @@ pub struct ConfigFile {
cleanup: Option<bool>,
notify_each_step: Option<bool>,
accept_all_windows_updates: Option<bool>,
skip_notify: Option<bool>,
bashit_branch: Option<String>,
only: Option<Vec<Step>>,
composer: Option<Composer>,
@@ -428,6 +429,10 @@ pub struct CommandLineArgs {
#[clap(short = 'k', long = "keep")]
keep_at_end: bool,
/// Skip sending a notification at the end of a run
#[clap(long = "skip-notify")]
skip_notify: bool,
/// Say yes to package manager's prompt
#[clap(short = 'y', long = "yes", arg_enum, multiple_values = true, min_values = 0)]
yes: Option<Vec<Step>>,
@@ -613,6 +618,15 @@ impl Config {
self.opt.keep_at_end || env::var("TOPGRADE_KEEP_END").is_ok()
}
/// Skip sending a notification at the end of a run
pub fn skip_notify(&self) -> bool {
if let Some(yes) = self.config_file.skip_notify {
return yes;
}
self.opt.skip_notify
}
/// Whether to set the terminal title
pub fn set_title(&self) -> bool {
self.config_file.set_title.unwrap_or(true)