Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
3.4 kB · 125 lines
Rust
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126use 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<String>, }, /// 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<String>, },}
#[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<String>, #[arg(long)] pub default_branch: Option<String>, /// optional at:// source annotation carried in registry state. #[arg(long)] pub source: Option<String>, /// 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<String>, #[arg(long)] pub default_branch: Option<String>,}
#[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<String>, }, /// check OAuth token and session status. Status,}