Extra options for distrobox (#83)
This commit is contained in:
@@ -107,3 +107,7 @@
|
||||
[flatpak]
|
||||
# Use sudo for updating the system-wide installation
|
||||
#use_sudo = true
|
||||
|
||||
[distrobox]
|
||||
#use_root = false
|
||||
#containers = ["archlinux-latest"]
|
||||
|
||||
@@ -172,6 +172,14 @@ pub struct Windows {
|
||||
enable_winget: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct Distrobox {
|
||||
use_root: Option<bool>,
|
||||
containers: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
@@ -293,6 +301,7 @@ pub struct ConfigFile {
|
||||
firmware: Option<Firmware>,
|
||||
vagrant: Option<Vagrant>,
|
||||
flatpak: Option<Flatpak>,
|
||||
distrobox: Option<Distrobox>,
|
||||
}
|
||||
|
||||
fn config_directory(base_dirs: &BaseDirs) -> PathBuf {
|
||||
@@ -615,7 +624,6 @@ impl Config {
|
||||
}
|
||||
|
||||
/// Extra Tmux arguments
|
||||
|
||||
pub fn tmux_arguments(&self) -> &Option<String> {
|
||||
&self.config_file.tmux_arguments
|
||||
}
|
||||
@@ -809,6 +817,20 @@ impl Config {
|
||||
.and_then(|linux| linux.dnf_arguments.as_deref())
|
||||
}
|
||||
|
||||
/// Distrobox use root
|
||||
pub fn distrobox_root(&self) -> bool {
|
||||
self.config_file
|
||||
.distrobox
|
||||
.as_ref()
|
||||
.and_then(|r| r.use_root)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Distrobox containers
|
||||
pub fn distrobox_containers(&self) -> Option<&Vec<String>> {
|
||||
self.config_file.distrobox.as_ref().and_then(|r| r.containers.as_ref())
|
||||
}
|
||||
|
||||
/// Concurrency limit for git
|
||||
pub fn git_concurrency_limit(&self) -> Option<usize> {
|
||||
self.config_file.git.as_ref().and_then(|git| git.max_concurrency)
|
||||
|
||||
@@ -607,14 +607,26 @@ pub fn run_protonup_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
pub fn run_distrobox_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
let distrobox = require("distrobox")?;
|
||||
|
||||
print_separator("distrobox");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(distrobox)
|
||||
.args(&["upgrade", "--all"])
|
||||
.check_run()
|
||||
print_separator("Distrobox");
|
||||
match (
|
||||
match (
|
||||
ctx.run_type().execute("distrobox").arg("upgrade"),
|
||||
ctx.config().distrobox_containers(),
|
||||
) {
|
||||
(r, Some(c)) => {
|
||||
if c.is_empty() {
|
||||
return Err(SkipStep("You need to specify at least one container".to_string()).into());
|
||||
}
|
||||
r.args(c)
|
||||
}
|
||||
(r, None) => r.arg("--all"),
|
||||
},
|
||||
ctx.config().distrobox_root(),
|
||||
) {
|
||||
(r, true) => r.arg("--root"),
|
||||
(r, false) => r,
|
||||
}
|
||||
.check_run()
|
||||
}
|
||||
|
||||
pub fn run_config_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user