diff --git a/src/common.rs b/src/common.rs index b690258..729cddc 100644 --- a/src/common.rs +++ b/src/common.rs @@ -42,8 +42,8 @@ pub enum Action { Drop, } +/// Provides required variables for Vento pub fn env_config() -> Result { - // Configures the directories for Vento let home = match dirs::home_dir() { Option::Some(dir) => dir, _ => PathBuf::new(), @@ -100,6 +100,7 @@ fn dir_config() -> Result { Ok(result) } +/// Writes an action into the history file pub fn history(data: HistoryData) -> Result<()> { let mut last_path = env_config()?.vento_dir; last_path.push("last"); diff --git a/src/help.rs b/src/help.rs index dedff27..8bcaa17 100644 --- a/src/help.rs +++ b/src/help.rs @@ -20,8 +20,8 @@ use anyhow::Result; use colored::Colorize; +/// Displays the help message for the vento command pub fn vento() -> Result<()> { - // A quick guide to move around in Vento println!( "{}, a CLI inventory for your files © 2022 Lux Aliaga. Licensed under GPLv3 @@ -43,8 +43,8 @@ pub fn vento() -> Result<()> { Ok(()) } +/// Displays the help message for the take command pub fn take() -> Result<()> { - // A quick guide to move around in Take println!( "{}, a file grabber for Vento © 2022 Lux Aliaga. Licensed under GPLv3 @@ -62,8 +62,8 @@ pub fn take() -> Result<()> { Ok(()) } +/// Displays the help message for the drop command pub fn drop() -> Result<()> { - // A quick guide to move around in Drop println!( "{}, a file dropper for Vento © 2022 Lux Aliaga. Licensed under GPLv3 diff --git a/src/inv.rs b/src/inv.rs index ae7aa7f..37d769b 100644 --- a/src/inv.rs +++ b/src/inv.rs @@ -25,8 +25,8 @@ use std::io::{self, Write}; use std::path::{Path, PathBuf}; use std::{fs, process}; +/// Initializes Vento by creating the respective directories it will use pub fn init() -> Result<()> { - // Initializes Vento let ventodir = &common::env_config()?.vento_dir; if ventodir.is_dir() { @@ -45,8 +45,8 @@ pub fn init() -> Result<()> { Ok(()) } +/// Lists files in the provided slot and/or directory pub fn list(slot: &str, dir: &str) -> Result<()> { - // Lists files in inventory let ventodir = &common::env_config()?.vento_dir; if !ventodir.is_dir() { @@ -164,8 +164,8 @@ pub fn list(slot: &str, dir: &str) -> Result<()> { Ok(()) } +/// Switches inevntory slots between each other, making the currently active inventory inactive and viceversa pub fn switch() -> Result<()> { - // Switches between inventory slots let ventodir = &common::env_config()?.vento_dir; let active = &common::env_config()?.active_dir; let inactive = &common::env_config()?.inactive_dir; @@ -183,8 +183,8 @@ pub fn switch() -> Result<()> { Ok(()) } +// Used only on init. Creates all required directories fn create_slots() -> Result<()> { - // Used only on init. Creates all required directories let active = &common::env_config()?.active_dir; let inactive = &common::env_config()?.inactive_dir; diff --git a/src/item.rs b/src/item.rs index ca32895..59233c7 100644 --- a/src/item.rs +++ b/src/item.rs @@ -24,8 +24,8 @@ use fs_extra::dir::{move_dir, CopyOptions}; use std::fs; use std::path::{Path, PathBuf}; +/// Takes a file or directory and stores it in an inventory slot pub fn take(file: &String, slot: &str, message: bool) -> Result<()> { - // Takes a file or directory let ventodir = &common::env_config()?.vento_dir; if !ventodir.is_dir() { @@ -100,6 +100,7 @@ pub fn take(file: &String, slot: &str, message: bool) -> Result<()> { Ok(()) } +/// Drops a file or directory and stores it in an inventory slot pub fn drop(file: &String, slot: &str, dest: PathBuf, message: bool) -> Result<()> { // Drops a file or directory let ventodir = &common::env_config()?.vento_dir; @@ -177,6 +178,7 @@ pub fn drop(file: &String, slot: &str, dest: PathBuf, message: bool) -> Result<( Ok(()) } +/// Undoes the last action made by Vento using the history file located on the Vento directory pub fn undo() -> Result<()> { let lastpath: PathBuf = [ common::env_config()?.vento_dir, @@ -209,7 +211,7 @@ pub fn undo() -> Result<()> { _ => bail!("Illegal action".red()), } - println!("✅ {}", "Last action undone".green(),); + println!("✅ {}", "Last action undone".green()); Ok(()) }