mirror of
https://git.sr.ht/~nixgoat/vento
synced 2024-11-23 15:25:19 +00:00
Compare commits
7 commits
b5c0818719
...
56c12f5d4e
Author | SHA1 | Date | |
---|---|---|---|
Lux Aliaga | 56c12f5d4e | ||
Lux Aliaga | 925513a136 | ||
Lux Aliaga | c1576270b9 | ||
Lux Aliaga | d80ccbea07 | ||
Lux Aliaga | 17217173f4 | ||
Lux Aliaga | 1e2fb49dac | ||
Lux Aliaga | 941d4c07d5 |
107
Cargo.lock
generated
107
Cargo.lock
generated
|
@ -141,22 +141,23 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "4.0.0"
|
||||
version = "5.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
|
||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.7"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
|
||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"winapi",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -174,14 +175,14 @@ dependencies = [
|
|||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"windows-sys",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fs_extra"
|
||||
version = "1.2.0"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
|
||||
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
|
@ -378,6 +379,12 @@ 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"
|
||||
|
@ -638,7 +645,7 @@ checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
|
|||
|
||||
[[package]]
|
||||
name = "vento"
|
||||
version = "1.2.0"
|
||||
version = "1.3.0-alpha"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"colored",
|
||||
|
@ -691,7 +698,16 @@ version = "0.45.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
"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",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -700,13 +716,28 @@ version = "0.42.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
"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",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -715,42 +746,84 @@ 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"
|
||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -1,11 +1,11 @@
|
|||
[package]
|
||||
name = "vento"
|
||||
version = "1.2.0"
|
||||
version = "1.3.0-alpha"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
|
||||
description = "A CLI inventory for your files"
|
||||
authors = ["Lux Aliaga <they@mint.lgbt>"]
|
||||
authors = ["Lux Aliaga <lux@nixgoat.me>"]
|
||||
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 = "4.0.0"
|
||||
colored = "2.0.0"
|
||||
fs_extra = "1.2.0"
|
||||
dirs = "5.0"
|
||||
colored = "2"
|
||||
fs_extra = "1.3"
|
||||
anyhow = "1.0"
|
||||
size_format = "1.0.2"
|
||||
config = "0.13.1"
|
||||
config = "0.13"
|
||||
xz2 = "0.1"
|
||||
tar = "0.4"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
![Vento](https://codeberg.org/nixgoat/vento/media/branch/master/assets/logo.png "Vento")
|
||||
![Vento](https://git.sr.ht/~nixgoat/vento/blob/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,6 +26,12 @@ 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.
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use crate::common;
|
||||
use crate::{
|
||||
common,
|
||||
message::{append_emoji, EmojiType}
|
||||
};
|
||||
use anyhow::Result;
|
||||
use colored::Colorize;
|
||||
use std::{fs::File, path::PathBuf};
|
||||
|
@ -40,7 +43,8 @@ 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(),
|
||||
|
@ -66,7 +70,8 @@ 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()
|
||||
);
|
||||
|
@ -89,7 +94,8 @@ 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(),
|
||||
|
@ -116,7 +122,8 @@ 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(),
|
||||
|
|
|
@ -22,12 +22,13 @@ use std::env;
|
|||
use std::path::Path;
|
||||
use vento::{
|
||||
common::get_current_dir,
|
||||
error::{throw_error, ErrorType},
|
||||
help, item,
|
||||
message::{throw_error, ErrorType},
|
||||
help, item, common::override_color
|
||||
};
|
||||
|
||||
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=") {
|
||||
|
|
|
@ -20,12 +20,13 @@
|
|||
use anyhow::Result;
|
||||
use std::env;
|
||||
use vento::{
|
||||
error::{throw_error, ErrorType},
|
||||
help, item,
|
||||
message::{throw_error, ErrorType},
|
||||
help, item, common::override_color
|
||||
};
|
||||
|
||||
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=") {
|
||||
|
|
|
@ -21,12 +21,13 @@ use anyhow::Result;
|
|||
use std::{env, path::PathBuf};
|
||||
use vento::{
|
||||
archive,
|
||||
error::{throw_error, ErrorType},
|
||||
help, history, inv,
|
||||
message::{throw_error, ErrorType},
|
||||
help, history, inv, common::override_color
|
||||
};
|
||||
|
||||
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
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use crate::error::{throw_error, ErrorType};
|
||||
use crate::message::{throw_error, ErrorType};
|
||||
use colored::control::set_override;
|
||||
use anyhow::Result;
|
||||
use config::Config;
|
||||
use std::env::current_dir;
|
||||
|
@ -38,6 +39,12 @@ 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,
|
||||
|
@ -53,7 +60,7 @@ pub fn env_config() -> Result<Settings> {
|
|||
if home == PathBuf::new() {
|
||||
throw_error(ErrorType::NoHomeDirectory)?;
|
||||
};
|
||||
let custom_dir = Path::new(&dir_config()?).to_path_buf();
|
||||
let custom_dir = Path::new(&parse_config()?.directory).to_path_buf();
|
||||
let vento_dir: PathBuf = if custom_dir != PathBuf::new() {
|
||||
Path::new(&custom_dir).to_path_buf()
|
||||
} else {
|
||||
|
@ -74,9 +81,11 @@ pub fn env_config() -> Result<Settings> {
|
|||
})
|
||||
}
|
||||
|
||||
fn dir_config() -> Result<String> {
|
||||
// Handles reading the config file or variables for Vento.
|
||||
let mut result = String::new();
|
||||
/// 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;
|
||||
let mut config = match dirs::config_dir() {
|
||||
Option::Some(dir) => dir,
|
||||
_ => PathBuf::new(),
|
||||
|
@ -92,14 +101,28 @@ fn dir_config() -> Result<String> {
|
|||
.add_source(config::Environment::with_prefix("VENTO"))
|
||||
.build()?;
|
||||
|
||||
result = match settings.get_string("directory") {
|
||||
directory = 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(result)
|
||||
Ok(DeserializedConfig {
|
||||
directory,
|
||||
display_emoji,
|
||||
display_colors,
|
||||
})
|
||||
}
|
||||
|
||||
/// Writes an action into the history file
|
||||
|
@ -140,3 +163,12 @@ 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(())
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
use crate::{
|
||||
common,
|
||||
error::{throw_error, ErrorType},
|
||||
message::{append_emoji, throw_error, ErrorType, EmojiType},
|
||||
inv, item,
|
||||
};
|
||||
use anyhow::Result;
|
||||
|
@ -64,7 +64,8 @@ pub fn undo() -> Result<()> {
|
|||
}
|
||||
|
||||
println!(
|
||||
"✅ {}{}{}",
|
||||
"{}{}{}{}",
|
||||
append_emoji(EmojiType::Success)?,
|
||||
match contents[3] {
|
||||
"take" => "Take",
|
||||
"drop" => "Drop",
|
||||
|
|
14
src/inv.rs
14
src/inv.rs
|
@ -19,7 +19,7 @@
|
|||
|
||||
use super::{
|
||||
common,
|
||||
error::{throw_error, ErrorType},
|
||||
message::{throw_error, append_emoji, ErrorType, EmojiType},
|
||||
};
|
||||
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) ", "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) ", append_emoji(EmojiType::Warning)?, "WARNING:".bold().red());
|
||||
let _ = io::stdout().flush();
|
||||
io::stdin().read_line(&mut answer)?;
|
||||
match answer.as_str().trim() {
|
||||
|
@ -89,7 +89,8 @@ 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 {
|
||||
|
@ -110,7 +111,8 @@ pub fn list(slot: &str, dir: &str) -> Result<()> {
|
|||
);
|
||||
} else {
|
||||
println!(
|
||||
"🗃️ {}",
|
||||
"{}{}",
|
||||
append_emoji(EmojiType::Inventory)?,
|
||||
format!(
|
||||
"Files in {}{} ({}):",
|
||||
match slot {
|
||||
|
@ -187,7 +189,7 @@ pub fn switch(message: bool) -> Result<()> {
|
|||
})?;
|
||||
|
||||
if message {
|
||||
println!("✅ {}", "Switched inventory slots!".green());
|
||||
println!("{}{}", append_emoji(EmojiType::Success)?, "Switched inventory slots!".green());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -200,6 +202,6 @@ fn create_slots() -> Result<()> {
|
|||
fs::create_dir_all(active)?;
|
||||
fs::create_dir_all(inactive)?;
|
||||
|
||||
println!("🎉 {}", "Vento has been succesfully initialized!".green());
|
||||
println!("{}{}", append_emoji(EmojiType::Celebrate)?, "Vento has been succesfully initialized!".green());
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
use super::{
|
||||
common,
|
||||
error::{throw_error, ErrorType},
|
||||
message::{throw_error, append_emoji, ErrorType, EmojiType},
|
||||
};
|
||||
use anyhow::{bail, Result};
|
||||
use colored::Colorize;
|
||||
|
@ -87,7 +87,8 @@ pub fn take(file: &String, slot: &str, message: bool) -> Result<()> {
|
|||
|
||||
if message {
|
||||
println!(
|
||||
"✅ {} {} {} {} {} {} {}",
|
||||
"{}{} {} {} {} {} {} {}",
|
||||
append_emoji(EmojiType::Success)?,
|
||||
"Took".green(),
|
||||
&filename.bold(),
|
||||
"from".green(),
|
||||
|
@ -171,7 +172,8 @@ 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(),
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
pub mod archive;
|
||||
pub mod common;
|
||||
pub mod error;
|
||||
pub mod message;
|
||||
pub mod help;
|
||||
pub mod history;
|
||||
pub mod inv;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
use anyhow::{bail, Result};
|
||||
use colored::Colorize;
|
||||
use crate::common::parse_config;
|
||||
|
||||
pub enum ErrorType {
|
||||
TooManyArgs,
|
||||
|
@ -35,6 +36,29 @@ 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!(
|
Loading…
Reference in a new issue