use std::path::PathBuf; use clap::{Args, Parser, Subcommand}; #[derive(Parser)] pub struct Cli { #[arg( long, global = true, env = "KNOT_STATIC_CONFIG", default_value = "knot-static.toml" )] pub config: PathBuf, #[command(subcommand)] pub command: Command, } #[derive(Subcommand)] pub enum Command { /// establish the knot's persistent admin/build state: identity, meta repo, signing key. Init, Repo { #[command(subcommand)] command: RepoCommand, }, Plc { #[command(subcommand)] command: PlcCommand, }, /// compile a complete immutable generation from the current knot state. Generate { /// optimization hint: project only this repo DID; routes stay globally coherent. #[arg(long)] repo: Option, }, /// validate and atomically make a completed generation live. Activate { generation: String }, #[command(name = "oauth")] OAuth { #[command(subcommand)] command: OAuthCommand, }, /// ssh ForceCommand entry point for the git user: serves fetches, accepts /// pushes (auto-provisioning unknown repos), then compiles + activates a /// new generation. never run interactively; sshd invokes it. GitSsh, /// run post-activation network tasks (mirror resync triggers and PDS record publishing). PostActivate { /// repo DIDs that changed in this activation. #[arg(long = "repo")] repos: Vec, }, } #[derive(Subcommand)] pub enum RepoCommand { Import(ImportArgs), Create(CreateArgs), /// print the registry projection: repoDid owner rkey name head source-path. List, /// emit the owner-side sh.tangled.repo record and its intended rkey. /// /// with --publish, also write it to the owner's PDS (resolved from the /// owner DID via the PLC) using an atproto app password. Record(RecordArgs), } #[derive(Args)] pub struct ImportArgs { #[arg(long)] pub owner: String, #[arg(long)] pub rkey: String, #[arg(long)] pub name: Option, #[arg(long)] pub default_branch: Option, /// optional at:// source annotation carried in registry state. #[arg(long)] pub source: Option, /// proceed even if git lfs pointer files are detected (static knots serve the /// pointers as-is; standard `git lfs pull` will not work). #[arg(long)] pub allow_lfs_pointers: bool, /// worktree or bare repository to import. pub path: PathBuf, } #[derive(Args)] pub struct RecordArgs { pub repo_did: String, /// publish the record to the owner's PDS via OAuth after emitting it. #[arg(long)] pub publish: bool, } #[derive(Args)] pub struct CreateArgs { #[arg(long)] pub owner: String, #[arg(long)] pub rkey: String, #[arg(long)] pub name: Option, #[arg(long)] pub default_branch: Option, } #[derive(Subcommand)] pub enum PlcCommand { /// retry all pending genesis operations; safe to run repeatedly. Sync, } #[derive(Subcommand)] pub enum OAuthCommand { /// perform interactive browser OAuth authorization for an owner DID. Login { #[arg(long)] owner: Option, }, /// check OAuth token and session status. Status, }