msgmerge/src/main.rs

57 lines
1.4 KiB
Rust

mod types;
mod commands;
mod services;
use std::collections::HashSet;
use clap::{command, ArgGroup, Parser};
use commands::{add::add, users::users};
use types::project::Project;
#[derive(Parser, Debug)]
#[command(
name = "msgexport",
version = env!("CARGO_PKG_VERSION"),
about = "Export and merge your messages between platforms",
author = "Jakub Žitník",
group = ArgGroup::new("command")
.args(&["new", "users", "add"])
.multiple(false)
.required(true)
)]
struct Cli {
#[arg(short = 'n', long = "new", help = "Create new msgexport project.", value_name = "OUTPUT_FILE")]
new: Option<String>,
#[arg(long = "users", help = "Add and remove users from the project.", value_name = "PROJECT_FILE")]
users: Option<String>,
#[arg(long = "add", help = "Add messages from a service.", value_name = "PROJECT_FILE")]
add: Option<String>,
}
#[tokio::main]
async fn main() {
let cli = Cli::parse();
if let Some(path) = cli.new {
let new_project = Project {
users: Vec::new(),
messages: Vec::new(),
timestamps: HashSet::new(),
media_index: 0,
};
let _ = new_project.save_new(path).await;
println!("New project was successfully created!");
}
if let Some(path) = cli.users {
users(path).await;
}
if let Some(path) = cli.add {
add(path).await;
}
}