src: Improve documentation

Also removes an extra unnecessary comma.
This commit is contained in:
Lux Aliaga 2022-10-26 16:49:45 -03:00
parent 26699fe765
commit 69ce377ec1
Signed by: lux
GPG Key ID: B56C805968637437
4 changed files with 13 additions and 10 deletions

View File

@ -42,8 +42,8 @@ pub enum Action {
Drop,
}
/// Provides required variables for Vento
pub fn env_config() -> Result<Settings> {
// 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<String> {
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");

View File

@ -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

View File

@ -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;

View File

@ -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(())
}