meowy-webring/cli/src/main.rs

30 lines
675 B
Rust
Raw Normal View History

use std::path::Path;
use arguments::{Arguments, Commands};
use clap::Parser;
use commands::{add, print, remove};
use shared::{directories, errors::Error};
mod arguments;
mod commands;
mod logging;
fn main() -> Result<(), Error> {
logging::initialize_logger()?;
let default_path = directories::get_names_path()?;
let args = Arguments::parse();
let path = match &args.path {
Some(path) => Path::new(path),
None => &default_path,
};
match &args.command {
Commands::Print { group, seperator, json } => print(path, group, seperator, *json)?,
Commands::Add { url, name } => add(path, url, name)?,
Commands::Remove { url } => remove(path, url)?,
};
Ok(())
}