use noosphere_core::data::Did;
use std::net::IpAddr;
use clap::Parser;
use clap::Subcommand;
use url::Url;
#[allow(missing_docs)]
#[derive(Debug, Parser)]
#[clap(name = "orb")]
#[clap(about = "A CLI tool for saving, syncing and sharing content to the Noosphere", long_about = Some(
r#"The orb CLI tool is a utility for saving, syncing and sharing content to the
Noosphere. In practical terms, this means it helps you with tasks such as key
management, creating and updating spheres, managing acccess to said spheres and
publishing the contents of those spheres to public networks."#))]
pub struct Cli {
#[clap(subcommand)]
pub command: OrbCommand,
}
#[allow(missing_docs)]
#[derive(Debug, Subcommand)]
pub enum OrbCommand {
Key {
#[clap(subcommand)]
command: KeyCommand,
},
Sphere {
#[clap(subcommand)]
command: SphereCommand,
},
Version {
#[clap(short, long)]
verbose: bool,
},
Serve {
#[clap(short, long)]
cors_origin: Option<Url>,
#[clap(short = 'I', long, default_value = "http://127.0.0.1:5001")]
ipfs_api: Url,
#[clap(short = 'N', long, default_value = "http://127.0.0.1:6667")]
name_resolver_api: Url,
#[clap(short, long, default_value = "127.0.0.1")]
interface: IpAddr,
#[clap(short, long, default_value = "4433")]
port: u16,
#[clap(long)]
storage_memory_cache_limit: Option<usize>,
},
}
#[derive(Debug, Subcommand)]
pub enum KeyCommand {
Create {
name: String,
},
#[clap(alias = "ls")]
List {
#[clap(short = 'j', long)]
as_json: bool,
},
}
#[derive(Debug, Subcommand)]
pub enum SphereCommand {
Create {
#[clap(short = 'k', long)]
owner_key: String,
},
Join {
#[clap(short = 'k', long)]
local_key: String,
#[clap(short = 'g', long)]
gateway_url: Url,
#[clap(short = 'a', long)]
authorization: Option<String>,
id: Did,
#[clap(short = 'd', long)]
render_depth: Option<u32>,
},
Status {
#[clap(long)]
id: bool,
},
Save {
#[clap(short = 'd', long)]
render_depth: Option<u32>,
},
Sync {
#[clap(short = 'r', long, default_value = "0")]
auto_retry: u32,
#[clap(short = 'd', long)]
render_depth: Option<u32>,
},
Render {
#[clap(short = 'd', long)]
render_depth: Option<u32>,
},
History,
#[allow(missing_docs)]
Follow {
#[clap(subcommand)]
command: FollowCommand,
},
#[allow(missing_docs)]
Config {
#[clap(subcommand)]
command: ConfigCommand,
},
#[allow(missing_docs)]
Auth {
#[clap(subcommand)]
command: AuthCommand,
},
}
#[derive(Debug, Subcommand)]
pub enum ConfigCommand {
Set {
#[allow(missing_docs)]
#[clap(subcommand)]
command: ConfigSetCommand,
},
Get {
#[allow(missing_docs)]
#[clap(subcommand)]
command: ConfigGetCommand,
},
}
#[derive(Debug, Subcommand)]
pub enum ConfigSetCommand {
GatewayUrl {
url: Url,
},
Counterpart {
did: String,
},
}
#[derive(Debug, Subcommand)]
pub enum ConfigGetCommand {
GatewayUrl,
Counterpart,
}
#[derive(Debug, Subcommand)]
pub enum AuthCommand {
Add {
did: Did,
#[clap(short = 'n', long)]
name: Option<String>,
},
List {
#[clap(short = 'j', long)]
as_json: bool,
#[clap(short = 't', long)]
tree: bool,
},
Revoke {
name: String,
},
Rotate {},
}
#[derive(Debug, Subcommand)]
pub enum FollowCommand {
Add {
name: Option<String>,
#[clap(short = 'i', long)]
sphere_id: Option<Did>,
},
Remove {
#[clap(short = 'n', long)]
by_name: Option<String>,
#[clap(short = 'i', long)]
by_sphere_id: Option<Did>,
},
Rename {
from: String,
#[clap(short = 't', long)]
to: Option<String>,
},
List {
#[clap(short = 'j', long)]
as_json: bool,
},
}