1
0
Fork 0
mirror of https://git.sr.ht/~nixgoat/vento synced 2024-11-23 07:14:27 +00:00

Compare commits

..

2 commits

Author SHA1 Message Date
Lux Aliaga b9cea29592
manifest: Bump version to v1.0.4
Another minor update! Really tiny and probably the last one in a good
while.
2022-10-01 17:40:08 -03:00
Lux Aliaga 4712c67bc2
src: Implemented clippy recommendations
Should make some code look less silly.
2022-10-01 17:38:14 -03:00
6 changed files with 28 additions and 28 deletions

2
Cargo.lock generated
View file

@ -592,7 +592,7 @@ checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
[[package]]
name = "vento"
version = "1.0.3"
version = "1.0.4"
dependencies = [
"anyhow",
"colored",

View file

@ -1,6 +1,6 @@
[package]
name = "vento"
version = "1.0.3"
version = "1.0.4"
edition = "2021"
readme = "README.md"

View file

@ -31,10 +31,10 @@ fn main() -> Result<()> {
create_dir_all(tempdir.clone())?;
for page in 0..pages.len() {
let tempfile = tempdir.join(pages[page].clone().1);
for page in &pages {
let tempfile = tempdir.join(page.clone().1);
let mut file = File::create(tempfile).unwrap();
write!(&mut file, "{}", pages[page].clone().0).unwrap();
write!(&mut file, "{}", page.clone().0).unwrap();
}
}
Ok(())

View file

@ -31,13 +31,13 @@ pub fn env_config() -> Result<Vec<PathBuf>> {
if home == PathBuf::new() {
bail!("{}", "Vento was unable to detect your home folder. Have you configured your environment correctly?".red());
};
let vento_dir: PathBuf;
let custom_dir = Path::new(&dir_config()?).to_path_buf();
if custom_dir != PathBuf::new() {
vento_dir = Path::new(&custom_dir).to_path_buf();
let vento_dir: PathBuf = if custom_dir != PathBuf::new() {
Path::new(&custom_dir).to_path_buf()
} else {
vento_dir = [home, Path::new(".vento").to_path_buf()].iter().collect();
}
[home, Path::new(".vento").to_path_buf()].iter().collect()
};
let active_dir = [&vento_dir, &Path::new("active").to_path_buf()]
.iter()
.collect();
@ -56,7 +56,7 @@ fn dir_config() -> Result<String> {
_ => PathBuf::new(),
};
if &config != &PathBuf::new() {
if config != PathBuf::new() {
config.push("vento.toml");
if config.is_file() {
let settings = Config::builder()

View file

@ -32,7 +32,7 @@ pub fn init() -> Result<()> {
if ventodir.is_dir() {
// Checks if Vento has already been initialized and prompts the user if they want to initialize it again
let mut answer = String::new();
print!("⚠️ {} {}", "WARNING:".bold().red(), "Vento has already been initialized. Reinitializing will delete all files on the directory for Vento. Do you wish to proceed? (y/N) ");
print!("⚠️ {} Vento has already been initialized. Reinitializing will delete all files on the directory for Vento. Do you wish to proceed? (y/N) ", "WARNING:".bold().red());
let _ = io::stdout().flush();
io::stdin()
.read_line(&mut answer)
@ -65,7 +65,7 @@ pub fn list(slot: &str, dir: &str) -> Result<()> {
_ => PathBuf::new(),
};
if dir != "" {
if !dir.is_empty() {
// Detects if the directory argument is not empty, and if so appends the path provided to the slot directory variable
slotdir = [&slotdir, &Path::new(dir).to_path_buf()].iter().collect();
}
@ -95,14 +95,14 @@ pub fn list(slot: &str, dir: &str) -> Result<()> {
format!(
"No files in {}{}.",
match slot {
"active" => format!("{}", slot).bold(),
"inactive" | _ => format!("{}", slot).blue().bold(),
"active" => slot.bold(),
_ => slot.blue().bold(),
},
if dir != "" {
if !dir.is_empty() {
if cfg!(windows) {
format!("\\{}", dir.to_string())
format!("\\{}", dir)
} else {
format!("/{}", dir.to_string())
format!("/{}", dir)
}
} else {
"".to_string()
@ -116,14 +116,14 @@ pub fn list(slot: &str, dir: &str) -> Result<()> {
format!(
"Files in {}{} ({}):",
match slot {
"active" => format!("{}", slot).bold(),
"inactive" | _ => format!("{}", slot).blue().bold(),
"active" => slot.bold(),
_ => slot.blue().bold(),
},
if dir != "" {
if !dir.is_empty() {
if cfg!(windows) {
format!("\\{}", dir.to_string())
format!("\\{}", dir)
} else {
format!("/{}", dir.to_string())
format!("/{}", dir)
}
} else {
" inventory".to_string()
@ -158,7 +158,7 @@ pub fn list(slot: &str, dir: &str) -> Result<()> {
SizeFormatterBinary::new(file.clone().metadata().unwrap().len())
)
} else {
format!("")
String::new()
}
);
}

View file

@ -24,7 +24,7 @@ use fs_extra::dir::{move_dir, CopyOptions};
use std::fs;
use std::path::{Path, PathBuf};
pub fn take(file: &String, slot: &String) -> Result<()> {
pub fn take(file: &String, slot: &str) -> Result<()> {
// Takes a file or directory
let ventodir = &common::env_config()?[0];
@ -35,7 +35,7 @@ pub fn take(file: &String, slot: &String) -> Result<()> {
"Vento not initialized. Run \"vento -i\" to initialize Vento.".red()
);
};
let slotdir: PathBuf = match slot.as_str() {
let slotdir: PathBuf = match slot {
"active" | "a" => common::env_config()?[1].clone(),
"inactive" | "i" => common::env_config()?[2].clone(),
_ => PathBuf::new(),
@ -92,7 +92,7 @@ pub fn take(file: &String, slot: &String) -> Result<()> {
Ok(())
}
pub fn drop(file: &String, slot: &String, dest: PathBuf) -> Result<()> {
pub fn drop(file: &String, slot: &str, dest: PathBuf) -> Result<()> {
// Drops a file or directory
let ventodir = &common::env_config()?[0];
@ -104,7 +104,7 @@ pub fn drop(file: &String, slot: &String, dest: PathBuf) -> Result<()> {
);
};
let slotdir: PathBuf = match slot.as_str() {
let slotdir: PathBuf = match slot {
"active" | "a" => common::env_config()?[1].clone(),
"inactive" | "i" => common::env_config()?[2].clone(),
_ => PathBuf::new(),