sneakerweb 1.2.0

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 crate::pwd::PwdArgs;
use crate::remove::RemoveArgs;
use crate::serve::ServeArgs;
use clap::{Parser, Subcommand};

#[derive(Subcommand)]
pub enum Commands {
    /// Register a new domain.
    ///
    /// A sneakerweb domain is a base-32-encoded public key, whose corresponding 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 directory where a sneakerweb collection
    /// is stored to specify patterns which should not be published to that collection 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 <path/to/collection>/blocked, which is a newline-delimited
    /// list of base-32 sneakerweb domain names.
    Block(BlockArgs),
    /// Remove a domain by deleting it, but don't add it to the blocklist.
    ///
    /// It will be possible to import the domain again later. You may specify multiple domains to be
    /// removed at once, and a path to a sneakerweb collection from which the domain(s) should be removed.
    ///
    /// You may specify a path to a collection of sneakerweb domains to remove from. If no such path is
    /// specified, sneakerwebsites will be removed from the default collection (either specified by the
    /// `DEFAULT_SNEAKERWEB_COLLECTION` environment variable, or ~/.sneakerweb if no default is set).
    Remove(RemoveArgs),
    /// 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.
    ///
    /// You may specify a path to a collection of sneakerweb domains to import into. If no such path is
    /// specified, sneakerwebsites will be imported into the default collection (either specified by the
    /// `DEFAULT_SNEAKERWEB_COLLECTION` environment variable, or ~/.sneakerweb if no default is set).
    Import(ImportArgs),
    /// Export your sneakerweb data to a .snk file.
    ///
    /// You may specify a subset of the domains in your collection to include by passing individual
    /// sneakerweb domains or the path of a file containing a newline-delimited list of them. 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.
    ///
    /// You may specify a path to a collection of sneakerweb domains to export from. If no such path is
    /// specified, sneakerwebsites will be exported from the default collection (either specified by the
    /// `DEFAULT_SNEAKERWEB_COLLECTION` environment variable, or ~/.sneakerweb if no default is set).
    Export(ExportArgs),
    /// Serve your local sneakerweb collection.
    ///
    /// The sneakerweb CLI starts a local webserver on port 1312 through which to browse your collection of
    /// sneakerwebsites.
    ///
    /// You may specify a path to a collection of sneakerweb domains to serve. If no such path is
    /// specified, sneakerwebsites will be served from the default collection (either specified by the
    /// `DEFAULT_SNEAKERWEB_COLLECTION` environment variable, or ~/.sneakerweb if no default is set).
    Serve(ServeArgs),
    /// Report the directory where your local sneakerweb collection is stored.
    ///
    /// This command is useful for troubleshooting whether the sneakerweb tool is using the
    /// directory you think it should be. The output will be just the path, without any other
    /// messages or text.
    Pwd(PwdArgs),
}

/// 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 files and storage can be found in each specified sneakerweb collection
/// location. The default collection location can be set though the DEFAULT_SNEAKERWEB_LOCATION
/// environment variable, or falls back to the ~/.sneakerweb directory if a default is not set.
#[derive(Parser)]
#[command(version, about)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}