use clap::Parser;
#[macro_use]
extern crate clap;
use rnostr::*;
#[derive(Debug, Parser)]
#[command(name = "rnostr", about = "Rnostr cli.", version)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Debug, Subcommand)]
enum Commands {
#[command(arg_required_else_help = true)]
Import(ImportOpts),
#[command(arg_required_else_help = true)]
Export(ExportOpts),
#[command(arg_required_else_help = true)]
Bench(BenchOpts),
Relay(RelayOpts),
Delete(DeleteOpts),
}
fn main() -> anyhow::Result<()> {
let args = Cli::parse();
match args.command {
Commands::Import(opts) => {
let total = import_opts(opts)?;
println!("imported {} events", total);
}
Commands::Export(opts) => {
export_opts(opts)?;
}
Commands::Bench(opts) => {
bench_opts(opts)?;
}
Commands::Relay(opts) => {
relay(&opts.config, opts.watch)?;
}
Commands::Delete(opts) => {
let count = delete(&opts.path, &opts.filter, opts.dry_run)?;
if opts.dry_run {
println!("Would delete {} events", count);
} else {
println!("Deleted {} events", count);
}
}
}
Ok(())
}