Dnf arguments (fix #314) (#405)

This commit is contained in:
Roey Darwish Dror
2020-05-14 09:22:14 +03:00
committed by GitHub
parent cf34294a32
commit 819447dcdf
4 changed files with 45 additions and 21 deletions

View File

@@ -1,5 +1,4 @@
use super::utils::editor;
#[cfg(target_os = "macos")]
use crate::terminal::print_warning;
use anyhow::Result;
use directories::BaseDirs;
@@ -56,6 +55,12 @@ pub struct Brew {
greedy_cask: Option<bool>,
}
#[derive(Deserialize, Default, Debug)]
pub struct Linux {
yay_arguments: Option<String>,
dnf_arguments: Option<String>,
}
#[derive(Deserialize, Default, Debug)]
pub struct Composer {
self_update: Option<bool>,
@@ -85,6 +90,7 @@ pub struct ConfigFile {
only: Option<Vec<Step>>,
composer: Option<Composer>,
brew: Option<Brew>,
linux: Option<Linux>,
}
impl ConfigFile {
@@ -402,12 +408,23 @@ impl Config {
}
/// Extra yay arguments
#[cfg(target_os = "linux")]
#[allow(dead_code)]
pub fn yay_arguments(&self) -> &str {
match &self.config_file.yay_arguments {
Some(args) => args.as_str(),
None => "--devel",
}
&self.config_file.yay_arguments.as_deref().map(|p| {
print_warning("Putting --yay-arguments in the top section is deprecated and will be removed in the future. Please move it to the [linux] section");
p
})
.or_else(|| self.config_file.linux.as_ref().and_then(|s| s.yay_arguments.as_deref()))
.unwrap_or("--devel")
}
/// Extra yay arguments
#[allow(dead_code)]
pub fn dnf_arguments(&self) -> Option<&str> {
self.config_file
.linux
.as_ref()
.and_then(|linux| linux.dnf_arguments.as_deref())
}
pub fn use_predefined_git_repos(&self) -> bool {