use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(name = "unifier")]
#[command(
about = "Filesystem postbox: programs communicate by writing values to files in a Unix tree",
version
)]
pub struct Cli {
#[arg(long, global = true, env = "UNIFIER_HOME")]
pub home: Option<std::path::PathBuf>,
#[arg(long, global = true, env = "UNIFIER_CHROOT")]
pub chroot: Option<String>,
#[arg(long, global = true)]
pub no_daemon: bool,
#[command(subcommand)]
pub cmd: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
Put {
key: String,
value: String,
},
Get {
key: String,
},
Del {
key: String,
},
Send {
#[arg(long)]
from: Option<String>,
recipient: String,
message: String,
},
Cron {
schedule: String,
message: String,
},
Poll {
recipient: String,
#[arg(long)]
ack: bool,
},
PollCron {
#[arg(long)]
ack: bool,
},
List {
path: String,
},
Ack {
id_or_path: String,
},
Root,
Event {
payload: String,
},
Message {
#[arg(long)]
from: String,
recipient: String,
payload: String,
},
#[command(subcommand)]
Tick(TickCommands),
#[command(subcommand)]
Daemon(DaemonCommands),
#[command(subcommand)]
Chroot(ChrootCommands),
}
#[derive(Subcommand)]
pub enum TickCommands {
Start {
#[arg(default_value = "default")]
label: String,
},
End,
Status,
Lock {
key: String,
},
Unlock {
key: String,
},
}
#[derive(Subcommand)]
pub enum DaemonCommands {
Start,
Run,
Stop,
Status,
Flush,
Watch,
}
#[derive(Subcommand)]
pub enum ChrootCommands {
Init {
name: String,
},
List,
}