Skip to content

Commit

Permalink
feat(manager): initial support for flatpak/zap
Browse files Browse the repository at this point in the history
  • Loading branch information
tulilirockz committed Apr 29, 2024
1 parent 1cd42c6 commit ca5bdea
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
25 changes: 25 additions & 0 deletions src/libexec/lib/manager_installers.nu
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ export def pipx_install [yes: bool, packages: list<string>] {
}
}

export def zap_install [yes: bool, packages: list<string>] {
for $package in $packages {
run-external zap install $package
}
}

export def flatpak_install [yes: bool, packages: list<string>] {
for $package in $packages {
run-external flatpak install $package
}
}

export def brew_install [yes: bool, packages: list<string>] {
let brew_path = "/home/linuxbrew/.linuxbrew/bin/brew"
if ((which brew | length) != 0) or ($brew_path | path exists) {
Expand Down Expand Up @@ -90,6 +102,19 @@ export def pipx_uninstall [yes: bool, packages: list<string>] {
}
}

export def zap_uninstall [yes: bool, packages: list<string>] {
for $package in $packages {
run-external zap remove $package
}
}

export def flatpak_uninstall [yes: bool, packages: list<string>] {
for $package in $packages {
run-external flatpak remove $package
}
run-external flatpak remove '--unused'
}

export def brew_uninstall [yes: bool, packages: list<string>] {
let brew_path = "/home/linuxbrew/.linuxbrew/bin/brew"
if ((which brew | length) == 0) and (not ($brew_path | path exists)) {
Expand Down
8 changes: 6 additions & 2 deletions src/libexec/manager.nu
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use lib/user_interaction.nu [user_prompt]
use lib/distrobox.nu [DISTROBOXES_META, gen_export_string]
use lib/manager_installers.nu [brew_install, nix_install, distrobox_install, pipx_install, brew_uninstall, nix_uninstall, distrobox_uninstall, pipx_uninstall]
use lib/manager_installers.nu [flatpak_install, zap_install, brew_install, nix_install, distrobox_install, pipx_install, brew_uninstall, nix_uninstall, distrobox_uninstall, pipx_uninstall]

# Available package managers: ["apt", "brew", "nix", "dnf", "yum", "paru", "pacman", "pipx"]
# Available package managers: ["apt", "brew", "nix", "dnf", "yum", "paru", "pacman", "pipx", "zap", "flatpak"]
export def "main manager" [] {
echo "Usage manager <command>."
}
Expand Down Expand Up @@ -60,6 +60,8 @@ export def "main manager install" [
nix => { nix_install $yes $packages ; exit 0 },
brew => { brew_install $yes $packages ; exit 0 },
pipx => { pipx_install $yes $packages ; exit 0 },
zap => { zap_install $yes $packages ; exit 0 },
flatpak => { flatpak_install $yes $packages ; exit 0 },
}

distrobox_install $package_data (match $package_manager {
Expand Down Expand Up @@ -108,6 +110,8 @@ export def "main manager remove" [
nix => { nix_uninstall $yes $packages ; exit 0 },
brew => { brew_uninstall $yes $packages ; exit 0 },
pipx => { pipx_uninstall $yes $packages ; exit 0 },
flatpak => { flatpak_uninstall $yes $packages ; exit 0 },
zap => { zap_uninstall $yes $packages ; exit 0 },
}

distrobox_uninstall $package_data (match $package_manager {
Expand Down

0 comments on commit ca5bdea

Please sign in to comment.