1
0
Fork 0
mirror of https://git.sr.ht/~nixgoat/vento synced 2025-07-27 15:41:22 +00:00

Compare commits

..

No commits in common. "56c12f5d4e4554add6c0abe13290fc2704c9ff0e" and "b5c0818719d5d7fc3e714786624525946abf63be" have entirely different histories.

13 changed files with 54 additions and 204 deletions

107
Cargo.lock generated
View file

@ -141,23 +141,22 @@ dependencies = [
[[package]]
name = "dirs"
version = "5.0.1"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-sys"
version = "0.4.1"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.48.0",
"winapi",
]
[[package]]
@ -175,14 +174,14 @@ dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"windows-sys 0.45.0",
"windows-sys",
]
[[package]]
name = "fs_extra"
version = "1.3.0"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
[[package]]
name = "generic-array"
@ -379,12 +378,6 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
[[package]]
name = "option-ext"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "ordered-multimap"
version = "0.4.3"
@ -645,7 +638,7 @@ checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
[[package]]
name = "vento"
version = "1.3.0-alpha"
version = "1.2.0"
dependencies = [
"anyhow",
"colored",
@ -698,16 +691,7 @@ version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [
"windows-targets 0.42.1",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets 0.48.5",
"windows-targets",
]
[[package]]
@ -716,28 +700,13 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
dependencies = [
"windows_aarch64_gnullvm 0.42.1",
"windows_aarch64_msvc 0.42.1",
"windows_i686_gnu 0.42.1",
"windows_i686_msvc 0.42.1",
"windows_x86_64_gnu 0.42.1",
"windows_x86_64_gnullvm 0.42.1",
"windows_x86_64_msvc 0.42.1",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.48.5",
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
@ -746,84 +715,42 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "xattr"
version = "0.2.3"

View file

@ -1,11 +1,11 @@
[package]
name = "vento"
version = "1.3.0-alpha"
version = "1.2.0"
edition = "2021"
readme = "README.md"
description = "A CLI inventory for your files"
authors = ["Lux Aliaga <lux@nixgoat.me>"]
authors = ["Lux Aliaga <they@mint.lgbt>"]
repository = "https://git.sr.ht/~nixgoat/vento"
license = "GPL-3.0-or-later"
@ -16,12 +16,12 @@ build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dirs = "5.0"
colored = "2"
fs_extra = "1.3"
dirs = "4.0.0"
colored = "2.0.0"
fs_extra = "1.2.0"
anyhow = "1.0"
size_format = "1.0.2"
config = "0.13"
config = "0.13.1"
xz2 = "0.1"
tar = "0.4"

View file

@ -1,4 +1,4 @@
![Vento](https://git.sr.ht/~nixgoat/vento/blob/master/assets/logo.png "Vento")
![Vento](https://codeberg.org/nixgoat/vento/media/branch/master/assets/logo.png "Vento")
[![Latest version](https://shields.io/crates/v/vento?color=red)](https://crates.io/crates/vento)
[![Downloads](https://shields.io/crates/d/vento)](https://crates.io/crates/vento)
@ -26,12 +26,6 @@ Clone the repository using `git`.
$ git clone https://git.sr.ht/~nixgoat/vento && cd vento
```
Check out to the latest stable release.
```
$ git checkout v1.2
```
### 2.a) cargo-make
This install method additionally installs the manpages for Vento. Make sure Rust, `cargo` and `cargo-make` are installed.

View file

@ -17,10 +17,7 @@
*
*/
use crate::{
common,
message::{append_emoji, EmojiType}
};
use crate::common;
use anyhow::Result;
use colored::Colorize;
use std::{fs::File, path::PathBuf};
@ -43,8 +40,7 @@ pub fn export_inv(slot: &str, output: PathBuf, message: bool) -> Result<()> {
if message {
println!(
"{}{} {} {} {}",
append_emoji(EmojiType::Success)?,
"✅ {} {} {} {}",
"Exported".green(),
match slot {
"a" | "active" => "active".green(),
@ -70,8 +66,7 @@ pub fn export_dir(output: PathBuf, message: bool) -> Result<()> {
if message {
println!(
"{}{} {}",
append_emoji(EmojiType::Success)?,
"✅ {} {}",
"Exported Vento directory into".green(),
&output.to_str().unwrap()
);
@ -94,8 +89,7 @@ pub fn import_inv(input: PathBuf, slot: &str, message: bool) -> Result<()> {
if message {
println!(
"{}{} {} {} {} {}",
append_emoji(EmojiType::Success)?,
"✅ {} {} {} {} {}",
"Imported".green(),
&input.to_str().unwrap(),
"into".green(),
@ -122,8 +116,7 @@ pub fn import_dir(input: PathBuf, message: bool) -> Result<()> {
if message {
println!(
"{}{} {} {}",
append_emoji(EmojiType::Success)?,
"✅ {} {} {}",
"Imported".green(),
&input.to_str().unwrap(),
"into Vento directory".green(),

View file

@ -22,13 +22,12 @@ use std::env;
use std::path::Path;
use vento::{
common::get_current_dir,
message::{throw_error, ErrorType},
help, item, common::override_color
error::{throw_error, ErrorType},
help, item,
};
fn main() -> Result<()> {
// Handles args in Drop
override_color()?;
let args: Vec<String> = env::args().collect();
if args.len() >= 2 {
if args[1].contains("--slot=") {

View file

@ -20,13 +20,12 @@
use anyhow::Result;
use std::env;
use vento::{
message::{throw_error, ErrorType},
help, item, common::override_color
error::{throw_error, ErrorType},
help, item,
};
fn main() -> Result<()> {
// Handles args in Vento
override_color()?;
let args: Vec<String> = env::args().collect();
if args.len() >= 2 {
if args[1].contains("--slot=") {

View file

@ -21,13 +21,12 @@ use anyhow::Result;
use std::{env, path::PathBuf};
use vento::{
archive,
message::{throw_error, ErrorType},
help, history, inv, common::override_color
error::{throw_error, ErrorType},
help, history, inv,
};
fn main() -> Result<()> {
// Handles args in Vento
override_color()?;
let args: Vec<String> = env::args().collect();
if args.len() >= 2 {
// If the vector for the arguments the command is taking is larger than 2, it most likely means the user has provided an argument

View file

@ -17,8 +17,7 @@
*
*/
use crate::message::{throw_error, ErrorType};
use colored::control::set_override;
use crate::error::{throw_error, ErrorType};
use anyhow::Result;
use config::Config;
use std::env::current_dir;
@ -39,12 +38,6 @@ pub struct HistoryData {
pub action: Action,
}
pub struct DeserializedConfig {
pub directory: String,
pub display_emoji: bool,
pub display_colors: bool,
}
pub enum Action {
Take,
Drop,
@ -60,7 +53,7 @@ pub fn env_config() -> Result<Settings> {
if home == PathBuf::new() {
throw_error(ErrorType::NoHomeDirectory)?;
};
let custom_dir = Path::new(&parse_config()?.directory).to_path_buf();
let custom_dir = Path::new(&dir_config()?).to_path_buf();
let vento_dir: PathBuf = if custom_dir != PathBuf::new() {
Path::new(&custom_dir).to_path_buf()
} else {
@ -81,11 +74,9 @@ pub fn env_config() -> Result<Settings> {
})
}
/// Handles reading the config file or variables for Vento.
pub fn parse_config() -> Result<DeserializedConfig> {
let mut directory = String::new();
let mut display_emoji = true;
let mut display_colors = true;
fn dir_config() -> Result<String> {
// Handles reading the config file or variables for Vento.
let mut result = String::new();
let mut config = match dirs::config_dir() {
Option::Some(dir) => dir,
_ => PathBuf::new(),
@ -101,28 +92,14 @@ pub fn parse_config() -> Result<DeserializedConfig> {
.add_source(config::Environment::with_prefix("VENTO"))
.build()?;
directory = match settings.get_string("directory") {
result = match settings.get_string("directory") {
Ok(value) => value,
Err(_) => String::new(),
};
display_emoji = match settings.get_bool("display_emoji") {
Ok(value) => value,
Err(_) => true,
};
display_colors = match settings.get_bool("display_colors") {
Ok(value) => value,
Err(_) => true,
};
}
};
Ok(DeserializedConfig {
directory,
display_emoji,
display_colors,
})
Ok(result)
}
/// Writes an action into the history file
@ -163,12 +140,3 @@ pub fn get_current_dir() -> Result<PathBuf> {
Ok(currentdir)
}
/// Sets color override if display_colors is disabled
pub fn override_color() -> Result<()> {
if !parse_config()?.display_colors {
set_override(false)
}
Ok(())
}

View file

@ -19,7 +19,6 @@
use anyhow::{bail, Result};
use colored::Colorize;
use crate::common::parse_config;
pub enum ErrorType {
TooManyArgs,
@ -36,29 +35,6 @@ pub enum ErrorType {
NoFileOrDir,
}
pub enum EmojiType {
Celebrate,
Success,
Warning,
Inventory,
}
pub fn append_emoji(message: EmojiType) -> Result<String> {
let mut output: String = String::new();
if parse_config()?.display_emoji {
match message {
EmojiType::Celebrate => output = String::from("🎉 "),
EmojiType::Success => output = String::from(""),
EmojiType::Inventory => output = String::from("🗃️ "),
EmojiType::Warning => output = String::from("⚠️ "),
};
}
Ok(output)
}
/// Displays an error and exits
pub fn throw_error(error: ErrorType) -> Result<()> {
bail!(

View file

@ -19,7 +19,7 @@
use crate::{
common,
message::{append_emoji, throw_error, ErrorType, EmojiType},
error::{throw_error, ErrorType},
inv, item,
};
use anyhow::Result;
@ -64,8 +64,7 @@ pub fn undo() -> Result<()> {
}
println!(
"{}{}{}{}",
append_emoji(EmojiType::Success)?,
"✅ {}{}{}",
match contents[3] {
"take" => "Take",
"drop" => "Drop",

View file

@ -19,7 +19,7 @@
use super::{
common,
message::{throw_error, append_emoji, ErrorType, EmojiType},
error::{throw_error, ErrorType},
};
use anyhow::{bail, Context, Result};
use colored::Colorize;
@ -35,7 +35,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!("{}{} Vento has already been initialized. Reinitializing will delete all files on the directory for Vento. Do you wish to proceed? (y/N) ", append_emoji(EmojiType::Warning)?, "WARNING:".bold().red());
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)?;
match answer.as_str().trim() {
@ -89,8 +89,7 @@ pub fn list(slot: &str, dir: &str) -> Result<()> {
if fs::read_dir(&slotdir).unwrap().count() == 0 {
// Detects if the slot or directory has any contents
println!(
"{}{}",
append_emoji(EmojiType::Inventory)?,
"🗃️ {}",
format!(
"No files in {}{}",
match slot {
@ -111,8 +110,7 @@ pub fn list(slot: &str, dir: &str) -> Result<()> {
);
} else {
println!(
"{}{}",
append_emoji(EmojiType::Inventory)?,
"🗃️ {}",
format!(
"Files in {}{} ({}):",
match slot {
@ -189,7 +187,7 @@ pub fn switch(message: bool) -> Result<()> {
})?;
if message {
println!("{}{}", append_emoji(EmojiType::Success)?, "Switched inventory slots!".green());
println!("{}", "Switched inventory slots!".green());
}
Ok(())
}
@ -202,6 +200,6 @@ fn create_slots() -> Result<()> {
fs::create_dir_all(active)?;
fs::create_dir_all(inactive)?;
println!("{}{}", append_emoji(EmojiType::Celebrate)?, "Vento has been succesfully initialized!".green());
println!("🎉 {}", "Vento has been succesfully initialized!".green());
Ok(())
}

View file

@ -19,7 +19,7 @@
use super::{
common,
message::{throw_error, append_emoji, ErrorType, EmojiType},
error::{throw_error, ErrorType},
};
use anyhow::{bail, Result};
use colored::Colorize;
@ -87,8 +87,7 @@ pub fn take(file: &String, slot: &str, message: bool) -> Result<()> {
if message {
println!(
"{}{} {} {} {} {} {} {}",
append_emoji(EmojiType::Success)?,
"✅ {} {} {} {} {} {} {}",
"Took".green(),
&filename.bold(),
"from".green(),
@ -172,8 +171,7 @@ pub fn drop(file: &String, slot: &str, dest: PathBuf, message: bool) -> Result<(
if message {
println!(
"{}{} {} {} {} {} {}",
append_emoji(EmojiType::Success)?,
"✅ {} {} {} {} {} {}",
"Dropped".green(),
&file.bold(),
"from".green(),

View file

@ -19,7 +19,7 @@
pub mod archive;
pub mod common;
pub mod message;
pub mod error;
pub mod help;
pub mod history;
pub mod inv;