Add no-self-update config and flag (#388)

This commit is contained in:
PolpOnline
2023-03-22 22:05:21 +01:00
committed by GitHub
parent 907465f891
commit 565aa405be
3 changed files with 16 additions and 1 deletions

View File

@@ -336,6 +336,7 @@ pub struct ConfigFile {
vagrant: Option<Vagrant>,
flatpak: Option<Flatpak>,
distrobox: Option<Distrobox>,
no_self_update: Option<bool>,
}
fn config_directory(base_dirs: &BaseDirs) -> PathBuf {
@@ -522,6 +523,10 @@ pub struct CommandLineArgs {
/// Print roff manpage and exit
#[clap(long, hide = true)]
pub gen_manpage: bool,
/// Don't update Topgrade
#[clap(long = "no-self-update")]
pub no_self_update: bool,
}
impl CommandLineArgs {
@@ -645,6 +650,11 @@ impl Config {
enabled_steps
}
/// Tell whether we should run a self update.
pub fn no_self_update(&self) -> bool {
self.opt.no_self_update || self.config_file.no_self_update.unwrap_or(false)
}
/// Tell whether we should run in tmux.
pub fn run_in_tmux(&self) -> bool {
self.opt.run_in_tmux || self.config_file.run_in_tmux.unwrap_or(false)