Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: remove pacstall options #60

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ build = "build.rs"
[dependencies]
anyhow = "1.0.58"
clap = { version = "~3.2.13", features = ["derive"] }
indoc = "1.0.6"

[build-dependencies]
clap = { version = "~3.2.13", features = ["derive"] }
Expand Down
20 changes: 2 additions & 18 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub enum Commands {
#[clap(group(
ArgGroup::new("operations")
.multiple(true)
.args(&["pacstall", "snapdpurge"]),
.args(&["snapdpurge"]),
))]
pub struct EnableCommand {
/// Run interactively
Expand All @@ -50,14 +50,6 @@ pub struct EnableCommand {
#[clap(short, long)]
pub interactive: bool,

/// Enable Pacstall, an additional AUR-like package manager for Ubuntu
///
/// Pacstall can be enabled via the rhino-config enable command. This will
/// download, install and keep Pacstall updated. Pacstall is an AUR-like
/// package manager for Ubuntu and Ubuntu-based systems
#[clap(short, long)]
pub pacstall: bool,

/// Remove Snapcraft (snapd) and replace it with Flatpak
///
/// This will be removing snapd from your system. It
Expand All @@ -73,17 +65,9 @@ pub struct EnableCommand {
ArgGroup::new("operations")
.required(true)
.multiple(true)
.args(&["pacstall", "snapdpurge"]),
.args(&["snapdpurge"]),
))]
pub struct DisableCommand {
/// Disable Pacstall, an additional AUR-like package manager for Ubuntu
///
/// This disables and uninstalls Pacstall from your system. Pacstall will
/// no longer be updated and all applications installed via Pacstall will
/// have to be manually updated or removed from your system
#[clap(short, long)]
pub pacstall: bool,

/// Install Snapcraft (snapd)
///
/// This reinstalls snapd on your system. Flatpak will still remain on your
Expand Down
41 changes: 0 additions & 41 deletions src/commands/disable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,6 @@ use std::process::Command;

use anyhow::{ensure, Context, Result};

pub fn pacstall(config_path: &Path) -> Result<()> {
fs::remove_file(&config_path).context("Unable to remove pacstall config file!")?;
println!("Pacstall has been disabled.");
println!("Removing pacstall...");

// Get the uninstall script from `curl` or `wget` depending upon which is
// installed on the system. Capture the output also.
let uninstall_script = if Command::new("curl").output()?.status.success() {
String::from_utf8(
Command::new("curl")
.args(["-fsSL", "https://git.io/JEZbi"])
.output()?
.stdout,
)?
} else {
String::from_utf8(
Command::new("wget")
.args(["-q", "https://git.io/JEZbi", "-O", "-"])
.output()?
.stdout,
)?
};
ensure!(Command::new("bash")
.args(["-c", &uninstall_script])
.status()?
.success());
Ok(())
}

pub fn snapdpurge(config_path: &Path) -> Result<()> {
fs::remove_file(&config_path).context("Unable to remove snapdpurge config file!")?;
println!("Snapdpurge has been disabled.");
Expand Down Expand Up @@ -73,18 +44,6 @@ mod tests {
#[fixture]
fn temp_dir() -> TempDir { tempdir().unwrap() }

#[rstest]
fn test_pacstall(temp_dir: TempDir) -> Result<(), Box<dyn Error>> {
let config_path = temp_dir.path().join("pacstall");
File::create(&config_path)?;

super::pacstall(&config_path)?;
// Test that the config file is deleted
assert!(!config_path.exists());

Ok(())
}

#[rstest]
fn test_snapdpurge(temp_dir: TempDir) -> Result<(), Box<dyn Error>> {
let config_path = temp_dir.path().join("snapdpurge");
Expand Down
25 changes: 0 additions & 25 deletions src/commands/enable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@ use std::path::Path;
use std::process::Command;

use anyhow::{ensure, Context, Result};
use indoc::indoc;

pub fn pacstall(config_path: &Path) -> Result<()> {
File::create(config_path).context("Unable to create pacstall config!")?;

println!(indoc!(
r#"
Pacstall has been enabled on the system, please check the
pacstall documentation on our website for information on how to
use this utility - please run "rhino-update" to update your system.
"#
));
Ok(())
}

pub fn snapdpurge(config_path: &Path, snap_path: &Path) -> Result<()> {
File::create(config_path).context("Failed to create the snapdpurge config!")?;
Expand Down Expand Up @@ -80,17 +66,6 @@ mod tests {
#[fixture]
fn temp_dir() -> TempDir { tempdir().unwrap() }

#[rstest]
fn test_pacstall(temp_dir: TempDir) -> Result<(), Box<dyn Error>> {
let config_path = temp_dir.path().join("pacstall");

super::pacstall(&config_path)?;
// Test that the config file is created
assert!(config_path.exists());

Ok(())
}

#[rstest]
fn test_snapdpurge(temp_dir: TempDir) -> Result<(), Box<dyn Error>> {
let config_path = temp_dir.path().join("snapdpurge");
Expand Down
8 changes: 2 additions & 6 deletions src/commands/switch_kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,7 @@ mod tests {

// Test that it errors out if the config file is already present
assert_eq!(
super::enable_libre(&config_path)
.unwrap_err()
.to_string(),
super::enable_libre(&config_path).unwrap_err().to_string(),
r#"The Libre kernel is already enabled! Run "rhino-update" to install it."#
);

Expand Down Expand Up @@ -280,9 +278,7 @@ mod tests {

// Test that it errors out if the config file is not present
assert_eq!(
super::disable_libre(&config_path)
.unwrap_err()
.to_string(),
super::disable_libre(&config_path).unwrap_err().to_string(),
r#"The Libre kernel is already disabled!"#
);
Ok(())
Expand Down
33 changes: 0 additions & 33 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ fn main() -> Result<()> {
let config_path = home_path.join(".rhino/config/");
fs::create_dir_all(&config_path).context("Failed to create config directory!")?;

let pacstall_config_path = config_path.join("pacstall");

let snapdpurge_config_path = config_path.join("snapdpurge");
let snapdpurge_snap_path = home_path.join("snap/");

Expand All @@ -68,20 +66,6 @@ fn main() -> Result<()> {
);
}
}

if !pacstall_config_path.exists() {
if ask(
"Do you wish to enable Pacstall, an additional AUR-like package manager \
for Ubuntu on this system?",
) {
enable::pacstall(&pacstall_config_path)?;
} else {
println!(
"No changes were made to the Rhino configuration, Pacstall has not \
been enabled."
);
}
}
}

if flag.snapdpurge {
Expand All @@ -92,14 +76,6 @@ fn main() -> Result<()> {
enable::snapdpurge(&snapdpurge_config_path, &snapdpurge_snap_path)?;
}

if flag.pacstall {
ensure!(
!pacstall_config_path.exists(),
"Pacstall is already enabled!"
);
enable::pacstall(&pacstall_config_path)?;
}

Ok(())
},
Commands::Disable(flag) => {
Expand All @@ -112,15 +88,6 @@ fn main() -> Result<()> {
disable::snapdpurge(&snapdpurge_config_path)?;
}

if flag.pacstall {
ensure!(
pacstall_config_path.exists(),
"Pacstall is already disabled!"
);

disable::pacstall(&pacstall_config_path)?;
}

Ok(())
},

Expand Down