mirror of https://git.sr.ht/~nixgoat/vento
inv: Don't display slot unless argument is passed
Similarly to item actions, when the slot argument is not passed, it is implied that the slot used is the active slot, therefore it is not necessary to reiterate it.
This commit is contained in:
parent
e9aa1b2ee1
commit
9589fcb674
|
@ -120,7 +120,11 @@ fn main() -> Result<()> {
|
|||
} else if cli.import_dir.is_some() {
|
||||
archive::import_dir(cli.import_dir.unwrap(), true)?
|
||||
} else {
|
||||
inv::list(cli.slot.unwrap_or(String::from("active")).as_str(), dir)?
|
||||
inv::list(
|
||||
cli.slot.clone().unwrap_or(String::from("active")).as_str(),
|
||||
dir,
|
||||
cli.slot.is_some(),
|
||||
)?
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
27
src/inv.rs
27
src/inv.rs
|
@ -49,7 +49,7 @@ pub fn init() -> Result<()> {
|
|||
}
|
||||
|
||||
/// Lists files in the provided slot and/or directory
|
||||
pub fn list(slot: &str, dir: &str) -> Result<()> {
|
||||
pub fn list(slot: &str, dir: &str, display_slot: bool) -> Result<()> {
|
||||
let ventodir = &common::env_config()?.vento_dir;
|
||||
|
||||
if !ventodir.is_dir() {
|
||||
|
@ -93,9 +93,13 @@ pub fn list(slot: &str, dir: &str) -> Result<()> {
|
|||
append_emoji(EmojiType::Inventory)?,
|
||||
format!(
|
||||
"No files in {}{}",
|
||||
match slot {
|
||||
"active" => slot.bold(),
|
||||
_ => slot.blue().bold(),
|
||||
if display_slot || dir != "" {
|
||||
match slot {
|
||||
"active" => slot.bold(),
|
||||
_ => slot.blue().bold(),
|
||||
}
|
||||
} else {
|
||||
"inventory".clear()
|
||||
},
|
||||
if !dir.is_empty() {
|
||||
if cfg!(windows) {
|
||||
|
@ -114,10 +118,17 @@ pub fn list(slot: &str, dir: &str) -> Result<()> {
|
|||
"{}{}",
|
||||
append_emoji(EmojiType::Inventory)?,
|
||||
format!(
|
||||
"Files in {}{} ({}):",
|
||||
match slot {
|
||||
"active" => slot.bold(),
|
||||
_ => slot.blue().bold(),
|
||||
"Files in{}{} ({}):",
|
||||
if display_slot || dir != "" {
|
||||
format!(
|
||||
" {}",
|
||||
match slot {
|
||||
"active" => slot.bold(),
|
||||
_ => slot.blue().bold(),
|
||||
},
|
||||
)
|
||||
} else {
|
||||
String::new()
|
||||
},
|
||||
if !dir.is_empty() {
|
||||
if cfg!(windows) {
|
||||
|
|
Loading…
Reference in New Issue