mirror of
https://git.sr.ht/~nixgoat/vento
synced 2025-12-08 13:30:14 +00:00
item: Don't display slot if not stated explicitly
It is implied that if you're working without the slot argument you are working with the active slot, therefore it's not needed for the message to output that.
This commit is contained in:
parent
63777e6f61
commit
1506dc811c
|
|
@ -40,11 +40,11 @@ struct Cli {
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
// Handles args in Drop
|
// Handles args in Drop
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
let unwrapped_slot = cli.slot.unwrap_or(String::from("active"));
|
let unwrapped_slot = cli.slot.clone().unwrap_or(String::from("active"));
|
||||||
let slot = unwrapped_slot.as_str();
|
let slot = unwrapped_slot.as_str();
|
||||||
let out = cli.output.unwrap_or(get_current_dir()?);
|
let out = cli.output.unwrap_or(get_current_dir()?);
|
||||||
|
|
||||||
item::drop(&cli.file, slot, out, true)?;
|
item::drop(&cli.file, slot, out, true, cli.slot.is_some())?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ fn main() -> Result<()> {
|
||||||
// Handles args in Vento
|
// Handles args in Vento
|
||||||
override_color()?;
|
override_color()?;
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
let slot = cli.slot.unwrap_or(String::from("active"));
|
let slot = cli.slot.clone().unwrap_or(String::from("active"));
|
||||||
|
|
||||||
item::take(&cli.file, &slot, true)?;
|
item::take(&cli.file, &slot, true, cli.slot.is_some())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,17 @@ pub fn undo() -> Result<()> {
|
||||||
match contents[3] {
|
match contents[3] {
|
||||||
"take" => {
|
"take" => {
|
||||||
let destpath = Path::new(contents[0]).to_path_buf();
|
let destpath = Path::new(contents[0]).to_path_buf();
|
||||||
item::drop(&String::from(contents[1]), contents[2], destpath, false)?;
|
item::drop(
|
||||||
|
&String::from(contents[1]),
|
||||||
|
contents[2],
|
||||||
|
destpath,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
"drop" => {
|
"drop" => {
|
||||||
let path = vec![contents[0], contents[1]].join("/");
|
let path = vec![contents[0], contents[1]].join("/");
|
||||||
item::take(&path, contents[2], false)?;
|
item::take(&path, contents[2], false, false)?;
|
||||||
}
|
}
|
||||||
"switch" => {
|
"switch" => {
|
||||||
inv::switch(false)?;
|
inv::switch(false)?;
|
||||||
|
|
|
||||||
32
src/item.rs
32
src/item.rs
|
|
@ -28,7 +28,7 @@ use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
/// Takes a file or directory and stores it in an inventory slot
|
/// Takes a file or directory and stores it in an inventory slot
|
||||||
pub fn take(file: &String, slot: &str, message: bool) -> Result<()> {
|
pub fn take(file: &String, slot: &str, message: bool, display_slot: bool) -> Result<()> {
|
||||||
let ventodir = &env_config()?.vento_dir;
|
let ventodir = &env_config()?.vento_dir;
|
||||||
|
|
||||||
if !ventodir.is_dir() {
|
if !ventodir.is_dir() {
|
||||||
|
|
@ -87,18 +87,21 @@ pub fn take(file: &String, slot: &str, message: bool) -> Result<()> {
|
||||||
|
|
||||||
if message {
|
if message {
|
||||||
println!(
|
println!(
|
||||||
"{}{} {} {}{} {} {}",
|
"{}{} {}{}{}",
|
||||||
append_emoji(EmojiType::Success)?,
|
append_emoji(EmojiType::Success)?,
|
||||||
"Took".green(),
|
"Took".green(),
|
||||||
&filename.bold(),
|
&filename.bold(),
|
||||||
match parse_config()?.display_dir {
|
match parse_config()?.display_dir {
|
||||||
true => format! {"{} {} ",
|
true => format! {"{} {} ",
|
||||||
"from".green(),
|
" from".green(),
|
||||||
&sourcelocation.to_str().unwrap(),
|
&sourcelocation.to_str().unwrap(),
|
||||||
},
|
},
|
||||||
_ => String::new(),
|
_ => String::new(),
|
||||||
},
|
},
|
||||||
"to".green(),
|
match display_slot {
|
||||||
|
true => format!(
|
||||||
|
"{} {} {}",
|
||||||
|
" to".green(),
|
||||||
match slot {
|
match slot {
|
||||||
"active" => slot.green(),
|
"active" => slot.green(),
|
||||||
"inactive" => slot.blue(),
|
"inactive" => slot.blue(),
|
||||||
|
|
@ -106,6 +109,9 @@ pub fn take(file: &String, slot: &str, message: bool) -> Result<()> {
|
||||||
}
|
}
|
||||||
.bold(),
|
.bold(),
|
||||||
"slot".green()
|
"slot".green()
|
||||||
|
),
|
||||||
|
_ => String::new(),
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,7 +119,13 @@ pub fn take(file: &String, slot: &str, message: bool) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Drops a file or directory and stores it in an inventory slot
|
/// Drops a file or directory and stores it in an inventory slot
|
||||||
pub fn drop(file: &String, slot: &str, dest: PathBuf, message: bool) -> Result<()> {
|
pub fn drop(
|
||||||
|
file: &String,
|
||||||
|
slot: &str,
|
||||||
|
dest: PathBuf,
|
||||||
|
message: bool,
|
||||||
|
display_slot: bool,
|
||||||
|
) -> Result<()> {
|
||||||
// Drops a file or directory
|
// Drops a file or directory
|
||||||
let ventodir = &env_config()?.vento_dir;
|
let ventodir = &env_config()?.vento_dir;
|
||||||
|
|
||||||
|
|
@ -177,11 +189,14 @@ pub fn drop(file: &String, slot: &str, dest: PathBuf, message: bool) -> Result<(
|
||||||
|
|
||||||
if message {
|
if message {
|
||||||
println!(
|
println!(
|
||||||
"{}{} {} {} {} {}{}",
|
"{}{} {}{}{}",
|
||||||
append_emoji(EmojiType::Success)?,
|
append_emoji(EmojiType::Success)?,
|
||||||
"Dropped".green(),
|
"Dropped".green(),
|
||||||
&file.bold(),
|
&file.bold(),
|
||||||
"from".green(),
|
match display_slot {
|
||||||
|
true => format!(
|
||||||
|
"{} {} {}",
|
||||||
|
" from".green(),
|
||||||
match slot {
|
match slot {
|
||||||
"active" => slot.green(),
|
"active" => slot.green(),
|
||||||
"inactive" => slot.blue(),
|
"inactive" => slot.blue(),
|
||||||
|
|
@ -189,6 +204,9 @@ pub fn drop(file: &String, slot: &str, dest: PathBuf, message: bool) -> Result<(
|
||||||
}
|
}
|
||||||
.bold(),
|
.bold(),
|
||||||
"slot".green(),
|
"slot".green(),
|
||||||
|
),
|
||||||
|
false => String::new(),
|
||||||
|
},
|
||||||
match parse_config()?.display_dir {
|
match parse_config()?.display_dir {
|
||||||
true => format! {"{} {} ",
|
true => format! {"{} {} ",
|
||||||
" into".green(),
|
" into".green(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue