sneakerweb 1.0.1

A parallel web transported by physical media
use crate::block::BlockArgs;
use crate::domain::DomainArgs;
use crate::export::ExportArgs;
use crate::import::ImportArgs;
use crate::publish::PublishArgs;
use clap::{Parser, Subcommand};

#[derive(Subcommand)]
pub enum Commands {
    /// Register a new domain.
    ///
    /// A sneakerweb domain is a base-16-encoded public key, whose correpsonding private
    /// key authorises publishing to that domain. In order to publish to a domain, you
    /// need both keys, so be sure to keep them somewhere safe.
    Domain(DomainArgs),
    /// Publish the contents of a directory to a domain you have the keypair for.
    ///
    /// .nopublish files containing newline-delimited lists of glob patterns can be used
    /// to specify files within the target directory which should not be published. A
    /// "global" nopublish file can be placed in the sneakerweb configuration directory
    /// (~/.sneakerweb) to specify patterns which should not be published from any directory.
    Publish(PublishArgs),
    /// Block a domain by deleting it and keeping its name in a list so that you don't import it again later.
    ///
    /// Blocked domains are recorded in ~/.sneakerweb/blocked, which is a newline-delimited
    /// list of base-16 sneakerweb domain names.
    Block(BlockArgs),
    /// Import data from a .snk file.
    ///
    /// When importing data from a domain you already store, the more recently published version is kept.
    ///
    /// This command automatically filters out any domains which appear in your blocklist, and warns you
    /// if any such domains occur in the .snk file. Additionally, you may specify whether to allow domains
    /// which you are not already storing to be imported, meaning that you can choose to receive updates to
    /// your existing sneakerwebsites without adding new ones. By default, all domains which are not explicitly
    /// blocked are imported.
    Import(ImportArgs),
    /// Export your sneakerweb data to a .snk file.
    ///
    /// You may specify a subset of the domains in your collection to include by providing a path to a file
    /// containing a newline-delimited list of base-16 sneakerweb domains. Only these domains will be written
    /// to the resulting .snk file. If you do not specify an explicit subset, then the full collection is exported.
    Export(ExportArgs),
    /// Serve your local sneakerweb collection.
    ///
    /// The sneakerweb CLI starts a local webserver on port 80 through which to browse your collection of
    /// sneakerwebsites.
    Serve,
}

/// A command-line interface for the sneakerweb.
///
/// The sneakerweb is a peer-to-peer protocol for web publishing without permission.
/// Anyone can claim any number of unique domains. Sneakerwebsites are stored on user devices,
/// and collections of sites can be transferred as .snk files by any means available.
/// Read more about it at https://www.sneakerweb.org.
///
/// Publishing consists of generating a domain with the `domain` command, and writing a directory
/// of web content to that domain with the `publish` command. Generate a .snk file to share your
/// sneakerwebsites using the `export` command, and add new ones to your collection by reading .snk
/// files from your community with the `import` command.
///
/// If you encounter sneakerweb content you don't want to see, use the `block` command to remove it,
/// and ensure that it isn't imported again in the future. Communities can moderate their local
/// sneakerweb by coordinating blocklists to prevent unwanted domains from propagating.
///
/// To browse the sneakerweb, simply run `sneakerweb serve`.
///
/// Sneakerweb configuration and storage can be found in the ~/.sneakerweb directory.
#[derive(Parser)]
#[command(version, about)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}