2023-07-02 01:27:03 +00:00
|
|
|
use std::path::Path;
|
2023-07-01 04:43:18 +00:00
|
|
|
use arguments::{Arguments, Commands};
|
|
|
|
use clap::Parser;
|
2023-07-01 06:12:55 +00:00
|
|
|
use commands::{add, print, remove};
|
2023-07-02 02:49:48 +00:00
|
|
|
use shared::{directories, errors::Error};
|
2023-07-01 04:43:18 +00:00
|
|
|
|
|
|
|
mod arguments;
|
|
|
|
mod commands;
|
2023-07-02 02:49:48 +00:00
|
|
|
mod logging;
|
2023-07-01 04:43:18 +00:00
|
|
|
|
2023-07-02 01:27:03 +00:00
|
|
|
fn main() -> Result<(), Error> {
|
2023-07-02 02:49:48 +00:00
|
|
|
logging::initialize_logger()?;
|
|
|
|
|
|
|
|
let default_path = directories::get_names_path()?;
|
2023-07-01 04:43:18 +00:00
|
|
|
let args = Arguments::parse();
|
2023-07-02 01:27:03 +00:00
|
|
|
|
|
|
|
let path = match &args.path {
|
|
|
|
Some(path) => Path::new(path),
|
|
|
|
None => &default_path,
|
|
|
|
};
|
2023-07-01 04:43:18 +00:00
|
|
|
|
|
|
|
match &args.command {
|
2023-07-02 03:49:59 +00:00
|
|
|
Commands::Print { group, seperator, json } => print(path, group, seperator, *json)?,
|
2023-07-02 01:27:03 +00:00
|
|
|
Commands::Add { url, name } => add(path, url, name)?,
|
|
|
|
Commands::Remove { url } => remove(path, url)?,
|
2023-07-01 06:12:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Ok(())
|
2023-07-01 04:43:18 +00:00
|
|
|
}
|