#![allow(clippy::large_enum_variant)]
use std::path::PathBuf;
use clap::{Parser, Subcommand, ValueEnum};
use nostr_sdk::prelude::*;
pub mod io;
pub mod parser;
#[derive(Debug, Parser)]
#[clap(author, version, about, long_about)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
Shell {
#[clap(long)]
relays: Vec<RelayUrl>,
},
Serve {
#[clap(long)]
port: Option<u16>,
},
Bunker,
}
#[derive(Debug, Parser)]
#[command(name = "")]
pub enum ShellCommand {
Generate,
#[command(arg_required_else_help = true)]
Sync {
public_key: PublicKey,
#[clap(long)]
relays: Vec<RelayUrl>,
#[clap(short, long, value_enum, default_value_t = ShellSyncDirection::Down)]
direction: ShellSyncDirection,
},
Query {
#[clap(long)]
id: Option<EventId>,
#[clap(short, long)]
author: Option<PublicKey>,
#[clap(short, long)]
kind: Option<Kind>,
#[clap(long)]
identifier: Option<String>,
#[clap(long)]
search: Option<String>,
#[clap(short, long)]
since: Option<Timestamp>,
#[clap(short, long)]
until: Option<Timestamp>,
#[clap(short, long)]
limit: Option<usize>,
#[clap(long)]
database: bool,
#[clap(long)]
print: bool,
#[clap(long)]
json: bool,
},
#[command(arg_required_else_help = true)]
Database {
#[command(subcommand)]
command: ShellCommandDatabase,
},
Exit,
}
#[derive(Debug, Subcommand)]
pub enum ShellCommandDatabase {
#[command(arg_required_else_help = true)]
Populate {
path: PathBuf,
},
Stats,
}
#[derive(Debug, Clone, ValueEnum)]
pub enum ShellSyncDirection {
Up,
Down,
Both,
}
impl From<ShellSyncDirection> for SyncDirection {
fn from(value: ShellSyncDirection) -> Self {
match value {
ShellSyncDirection::Up => Self::Up,
ShellSyncDirection::Down => Self::Down,
ShellSyncDirection::Both => Self::Both,
}
}
}