radrootsd

JSON-RPC bridge for Radroots event publishing
git clone https://radroots.dev/git/radrootsd.git
Log | Files | Refs | README | LICENSE

cli.rs (2257B)


      1 use std::path::PathBuf;
      2 
      3 use clap::{ArgAction, Args as ClapArgs, Parser, Subcommand, ValueHint};
      4 
      5 #[derive(ClapArgs, Debug, Clone)]
      6 pub struct ServiceCliArgs {
      7     #[arg(
      8         long,
      9         value_name = "PATH",
     10         value_hint = ValueHint::FilePath,
     11         help = "Path to the daemon configuration file; no implicit cwd-rooted default is used"
     12     )]
     13     pub config: Option<PathBuf>,
     14     #[arg(
     15         long,
     16         value_name = "PATH",
     17         value_hint = ValueHint::FilePath,
     18         help = "Path to the daemon encrypted identity envelope"
     19     )]
     20     pub identity: Option<PathBuf>,
     21     #[arg(
     22         long,
     23         action = ArgAction::SetTrue,
     24         help = "Allow generating a new encrypted identity when the configured path is missing"
     25     )]
     26     pub allow_generate_identity: bool,
     27 }
     28 
     29 #[derive(Parser, Debug, Clone)]
     30 #[command(
     31     about = env!("CARGO_PKG_DESCRIPTION"),
     32     author = env!("CARGO_PKG_AUTHORS"),
     33     version = env!("CARGO_PKG_VERSION")
     34 )]
     35 pub struct Args {
     36     #[command(flatten)]
     37     pub service: ServiceCliArgs,
     38     #[command(subcommand)]
     39     pub command: Option<Command>,
     40 }
     41 
     42 #[derive(Subcommand, Debug, Clone)]
     43 pub enum Command {
     44     TransportPublish(TransportPublishCommand),
     45 }
     46 
     47 #[derive(ClapArgs, Debug, Clone)]
     48 pub struct TransportPublishCommand {
     49     #[command(subcommand)]
     50     pub command: TransportPublishSubcommand,
     51 }
     52 
     53 #[derive(Subcommand, Debug, Clone)]
     54 pub enum TransportPublishSubcommand {
     55     Principal(PrincipalCommand),
     56 }
     57 
     58 #[derive(ClapArgs, Debug, Clone)]
     59 pub struct PrincipalCommand {
     60     #[command(subcommand)]
     61     pub command: PrincipalSubcommand,
     62 }
     63 
     64 #[derive(Subcommand, Debug, Clone)]
     65 pub enum PrincipalSubcommand {
     66     Init(PrincipalInitArgs),
     67 }
     68 
     69 #[derive(ClapArgs, Debug, Clone)]
     70 pub struct PrincipalInitArgs {
     71     #[arg(long)]
     72     pub label: String,
     73     #[arg(long)]
     74     pub token_file: PathBuf,
     75     #[arg(long)]
     76     pub allowed_pubkey: Vec<String>,
     77     #[arg(long)]
     78     pub allowed_kind: Vec<u32>,
     79     #[arg(long)]
     80     pub allowed_target_policy: Vec<String>,
     81     #[arg(long)]
     82     pub allowed_explicit_transport_kind: Vec<String>,
     83     #[arg(long)]
     84     pub allowed_nostr_source_policy: Vec<String>,
     85     #[arg(long)]
     86     pub job_visibility: String,
     87     #[arg(long)]
     88     pub allow_request_targets: bool,
     89 }