2022-09-26 19:54:39 +00:00
|
|
|
/*
|
|
|
|
|
* Vento, a CLI inventory for your files.
|
|
|
|
|
* Copyright (C) 2022 Lux Aliaga
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
use anyhow::{bail, Result};
|
|
|
|
|
use colored::Colorize;
|
|
|
|
|
use std::env;
|
2022-11-03 22:26:15 +00:00
|
|
|
use vento::{help, history, inv};
|
2022-09-26 19:54:39 +00:00
|
|
|
|
|
|
|
|
fn main() -> Result<()> {
|
2022-09-27 23:05:08 +00:00
|
|
|
// Handles args in Vento
|
2022-09-26 19:54:39 +00:00
|
|
|
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
|
|
|
|
|
if args[1].contains("--slot=") {
|
2022-09-27 23:05:08 +00:00
|
|
|
// Checks if the user has provided the long argument "--slot="
|
2022-09-26 19:54:39 +00:00
|
|
|
match args.len() {
|
|
|
|
|
3 => inv::list(&args[1].replace("--slot=", ""), &args[2])?,
|
|
|
|
|
2 => inv::list(&args[1].replace("--slot=", ""), "")?,
|
2022-09-27 22:16:18 +00:00
|
|
|
_ => bail!("{}", "Too many arguments".red()),
|
2022-09-26 19:54:39 +00:00
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
match args[1].as_str() {
|
|
|
|
|
"-h" | "--help" => help::vento()?,
|
|
|
|
|
"-i" | "--init" => inv::init()?,
|
|
|
|
|
"-c" | "--switch" => inv::switch()?,
|
2022-11-03 22:26:15 +00:00
|
|
|
"-u" | "--undo" => history::undo()?,
|
2022-09-26 19:54:39 +00:00
|
|
|
"-s" => match args.len() {
|
|
|
|
|
4 => inv::list(&args[2], &args[3])?,
|
|
|
|
|
3 => inv::list(&args[2], "")?,
|
2022-11-03 22:08:50 +00:00
|
|
|
2 => bail!("{}", "You need to specify a slot".red()),
|
2022-09-27 22:16:18 +00:00
|
|
|
_ => bail!("{}", "Too many arguments".red()),
|
2022-09-26 19:54:39 +00:00
|
|
|
},
|
|
|
|
|
_ => inv::list("active", args[1].as_str())?,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2022-09-27 23:05:08 +00:00
|
|
|
// If the user provides no arguments, Vento will display the files in the active slot.
|
2022-09-26 19:54:39 +00:00
|
|
|
inv::list("active", "")?;
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|