diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dfc9c38..161f3a0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,9 +16,12 @@ ### Good Practices - Try to use .unwrap() as little as possible -- Try to never use panic!() in production code, always try to have a possible way to resolve errors, even if it's just unwrap_or/_else() -- Never use println!() or eprintln!() in finalised code. Using string functions (e.g. info() in Amethyst v3.0.0) is preferred -- Compartmentalise as much as you can, avoid writing the exact same line of code 50 times if you can turn it into a function +- Try to never use panic!() in production code, always try to have a possible way to resolve errors, even if it's just + unwrap_or/_else() +- Never use println!() or eprintln!() in finalised code. Using string functions (e.g. info() in Amethyst v3.0.0) is + preferred +- Compartmentalise as much as you can, avoid writing the exact same line of code 50 times if you can turn it into a + function ### Examples of these guidelines in practice diff --git a/README.md b/README.md index 98d072e..455dfb0 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ Made for Crystal, compatible with any Arch-based Linux distribution.

| 6 | User cancelled package installation | | 7 | Pacman error when installing package | - ## How to build: Tested on latest Cargo (1.60.0-nightly) diff --git a/src/database/add.rs b/src/database/add.rs index bf4620b..7947578 100644 --- a/src/database/add.rs +++ b/src/database/add.rs @@ -3,15 +3,15 @@ use std::path::Path; use rusqlite::Connection; -use crate::internal::rpc::Package; use crate::{crash, log, Options}; +use crate::internal::rpc::Package; pub fn add(pkg: Package, options: Options) { let conn = Connection::open(Path::new(&format!( "{}/.local/share/ame/db.sqlite", env::var("HOME").unwrap() ))) - .expect("Couldn't connect to database"); + .expect("Couldn't connect to database"); if options.verbosity >= 1 { log(format!("Adding package {} to database", pkg.name)); diff --git a/src/database/initialise.rs b/src/database/initialise.rs index 01d92b9..2f4e558 100644 --- a/src/database/initialise.rs +++ b/src/database/initialise.rs @@ -31,8 +31,8 @@ pub fn init(options: Options) { )", [], ) - .unwrap_or_else(|e| { - crash(format!("Couldn't initialise database: {}", e), 3); - 1 - }); + .unwrap_or_else(|e| { + crash(format!("Couldn't initialise database: {}", e), 3); + 1 + }); } diff --git a/src/database/query.rs b/src/database/query.rs index d12470d..7ec0ccc 100644 --- a/src/database/query.rs +++ b/src/database/query.rs @@ -3,8 +3,8 @@ use std::path::Path; use rusqlite::Connection; -use crate::internal::rpc::Package; use crate::{log, Options}; +use crate::internal::rpc::Package; pub fn query(options: Options) -> Vec { let verbosity = options.verbosity; @@ -17,7 +17,7 @@ pub fn query(options: Options) -> Vec { "{}/.local/share/ame/db.sqlite", env::var("HOME").unwrap() ))) - .expect("Couldn't connect to database"); + .expect("Couldn't connect to database"); if verbosity >= 1 { log("Querying database for input".to_string()); diff --git a/src/database/remove.rs b/src/database/remove.rs index c213e3b..d538415 100644 --- a/src/database/remove.rs +++ b/src/database/remove.rs @@ -10,7 +10,7 @@ pub fn remove(pkg: &str, options: Options) { "{}/.local/share/ame/db.sqlite", env::var("HOME").unwrap() ))) - .expect("Couldn't connect to database"); + .expect("Couldn't connect to database"); let verbosity = options.verbosity; @@ -26,5 +26,5 @@ pub fn remove(pkg: &str, options: Options) { WHERE name = ?);", [pkg], ) - .expect("Couldn't delete package from database"); + .expect("Couldn't delete package from database"); } diff --git a/src/internal/mod.rs b/src/internal/mod.rs index 06c7006..66bdeae 100644 --- a/src/internal/mod.rs +++ b/src/internal/mod.rs @@ -50,4 +50,4 @@ macro_rules! uwu { uwu }}; -} +} \ No newline at end of file diff --git a/src/internal/sort.rs b/src/internal/sort.rs index 64d6430..56c3cac 100644 --- a/src/internal/sort.rs +++ b/src/internal/sort.rs @@ -1,7 +1,7 @@ use std::process::{Command, Stdio}; -use crate::internal::strings::log; use crate::internal::{clean, rpc, structs}; +use crate::internal::strings::log; use crate::Options; pub fn sort(input: &[String], options: Options) -> structs::Sorted { diff --git a/src/internal/strings.rs b/src/internal/strings.rs index 2850ee8..33ee359 100644 --- a/src/internal/strings.rs +++ b/src/internal/strings.rs @@ -1,8 +1,8 @@ +use std::{env, io}; use std::io::Write; use std::process::exit; use std::str::FromStr; use std::time::UNIX_EPOCH; -use std::{env, io}; use crate::uwu; diff --git a/src/main.rs b/src/main.rs index a724c27..3489c17 100644 --- a/src/main.rs +++ b/src/main.rs @@ -199,9 +199,9 @@ fn main() { .unwrap() .is_present("repo") && !matches - .subcommand_matches("search") - .unwrap() - .is_present("aur") + .subcommand_matches("search") + .unwrap() + .is_present("aur") { info(format!("Searching AUR and repos for {}", &packages[0])); operations::search(&packages[0], options); diff --git a/src/operations/aur_install.rs b/src/operations/aur_install.rs index aa1c209..4a8533e 100644 --- a/src/operations/aur_install.rs +++ b/src/operations/aur_install.rs @@ -4,9 +4,9 @@ use std::fs::remove_dir_all; use std::path::Path; use std::process::{Command, Stdio}; -use crate::internal::rpc::rpcinfo; -use crate::internal::{crash, prompt}; use crate::{info, log, Options}; +use crate::internal::{crash, prompt}; +use crate::internal::rpc::rpcinfo; pub fn aur_install(a: Vec, options: Options) { let url = crate::internal::rpc::URL; diff --git a/src/operations/search.rs b/src/operations/search.rs index 08d5006..053d9fd 100644 --- a/src/operations/search.rs +++ b/src/operations/search.rs @@ -1,7 +1,7 @@ use std::process::Command; -use crate::internal::rpc::rpcsearch; use crate::{log, Options}; +use crate::internal::rpc::rpcsearch; pub fn aur_search(a: &str, options: Options) { let verbosity = options.verbosity; diff --git a/src/operations/uninstall.rs b/src/operations/uninstall.rs index 0e2ef05..405f7ce 100644 --- a/src/operations/uninstall.rs +++ b/src/operations/uninstall.rs @@ -1,5 +1,5 @@ -use std::path::Path; use std::{env, fs}; +use std::path::Path; use crate::{log, Options}; @@ -39,7 +39,7 @@ pub fn uninstall(mut a: Vec, options: Options) { env::var("HOME").unwrap(), b ))) - .unwrap(); + .unwrap(); } } } diff --git a/src/operations/upgrade.rs b/src/operations/upgrade.rs index d80c824..1a761a0 100644 --- a/src/operations/upgrade.rs +++ b/src/operations/upgrade.rs @@ -1,8 +1,8 @@ use runas::Command; +use crate::{info, log, Options}; use crate::internal::rpc::rpcinfo; use crate::operations::aur_install::aur_install; -use crate::{info, log, Options}; pub fn upgrade(options: Options) { let verbosity = options.verbosity;