diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-04-28 18:55:32 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-04-28 18:55:32 +0200 |
commit | 547539bad0e4c35b519b0591fa5f41809cbd921d (patch) | |
tree | 9ccc641204b1dc8c8293b82364d1a6fc5455836a | |
parent | f03d34b9b359ac137015b0529a651fd7c4beb69f (diff) |
Remove old code, start rewrite
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/cli_ui.rs | 453 | ||||
-rw-r--r-- | src/typeext/block.rs | 59 | ||||
-rw-r--r-- | src/typeext/mod.rs | 1 |
3 files changed, 0 insertions, 513 deletions
diff --git a/src/cli_ui.rs b/src/cli_ui.rs deleted file mode 100644 index d105041..0000000 --- a/src/cli_ui.rs +++ /dev/null @@ -1,453 +0,0 @@ -use clap::{Arg, App, SubCommand}; - -pub fn build_ui<'a>() -> App<'a, 'a> { - App::new("distrox") - .version("0.1.0") - .author("Matthias Beyer <mail@beyermatthias.de>") - .about("Distributed Social Network Application") - - .subcommand(SubCommand::with_name("gui") - .about("Start the GUI application") - .version("0.1.0") - ) - - // - // "Plumbing" commands - // - - .subcommand(SubCommand::with_name("is-block") - .about("Check whether hash is-block") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - - // Checker commands - - .subcommand(SubCommand::with_name("is-content") - .about("Check whether hash is-content") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - .subcommand(SubCommand::with_name("is-post") - .about("Check whether hash is-post") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - .subcommand(SubCommand::with_name("is-reply") - .about("Check whether hash is-reply") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - .subcommand(SubCommand::with_name("is-profile") - .about("Check whether hash is-profile") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - - // block commands - - .subcommand(SubCommand::with_name("get-parent-blocks") - .about("Get parent blocks of a block") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - .subcommand(SubCommand::with_name("get-content-of-block") - .about("Get content of block") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - - // content commands - - .subcommand(SubCommand::with_name("get-devices") - .about("Get devices of content blob identified by hash") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - .subcommand(SubCommand::with_name("get-payload-type") - .about("Get payload type of content blob identified by hash") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - .subcommand(SubCommand::with_name("get-payload") - .about("Get payload of content blob identified by hash") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - - // content-post commands - - .subcommand(SubCommand::with_name("get-post-content") - .about("Get content of post identified by hash") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - .subcommand(SubCommand::with_name("get-post-content-format") - .about("Get content format of post identified by hash") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - .subcommand(SubCommand::with_name("get-post-reply-to") - .about("Get 'reply-to' hash of post identified by hash") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - .subcommand(SubCommand::with_name("get-post-metadata") - .about("Get metadata of post identified by hash") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - - // content-profile commands - - .subcommand(SubCommand::with_name("get-profile-names") - .about("Get profile names of profile blob identified by hash") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - .subcommand(SubCommand::with_name("get-profile-picture") - .about("Get profile picture hash of profile blob identified by hash") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - .subcommand(SubCommand::with_name("get-profile-more") - .about("Get 'more' profile data from profile blob identified by hash") - .version("0.1.0") - .arg(Arg::with_name("HASH") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - - // Writer commands - - .subcommand(SubCommand::with_name("create-post-blob") - .about("") - .version("0.1.0") - .arg(Arg::with_name("device") - .long("device") - .required(true) - .takes_value(true) - .multiple(true) - .help("") - ) - .arg(Arg::with_name("timestamp") - .long("timestamp") - .required(false) - .takes_value(true) - .multiple(false) - .help("") - ) - .arg(Arg::with_name("content-format") - .long("format") - .required(true) - .takes_value(true) - .multiple(false) - .help("Mimetype of the content pointed to by the hash from --content") - ) - .arg(Arg::with_name("content-hash") - .long("content") - .required(true) - .takes_value(true) - .multiple(false) - .help("IPFS hash of the content") - ) - .arg(Arg::with_name("replyto-hash") - .long("reply-to") - .required(false) - .takes_value(true) - .multiple(false) - .help("IPFS hash of post which this post replies to") - ) - .arg(Arg::with_name("comments-will-be-propagated") - .long("propagate-comments") - .required(false) - .takes_value(false) - .multiple(false) - .help("Add flag that comments will be propagated") - ) - .arg(Arg::with_name("comments-will-be-propagated-until") - .long("propagate-comments-until") - .required(false) - .takes_value(true) - .multiple(false) - .help("Add flag that comments will be propagated until a date") - ) - ) - .subcommand(SubCommand::with_name("create-attached-post-comments-blob") - .about("") - .version("0.1.0") - .arg(Arg::with_name("device") - .long("device") - .required(true) - .takes_value(true) - .multiple(true) - .help("") - ) - .arg(Arg::with_name("timestamp") - .long("timestamp") - .required(false) - .takes_value(true) - .multiple(false) - .help("") - ) - .arg(Arg::with_name("comments-for") - .long("comments-for") - .short("f") - .required(true) - .takes_value(true) - .multiple(false) - .help("IPFS hash of the post the comments are propagated for") - ) - .arg(Arg::with_name("refs") - .long("ref") - .short("r") - .required(true) // would work without, but is senseless - .takes_value(true) - .multiple(true) - .help("IPFS hashes of top-level comments to this post") - ) - ) - .subcommand(SubCommand::with_name("create-profile-blob") - .about("") - .version("0.1.0") - .arg(Arg::with_name("device") - .long("device") - .required(true) - .takes_value(true) - .multiple(true) - .help("") - ) - .arg(Arg::with_name("timestamp") - .long("timestamp") - .required(false) - .takes_value(true) - .multiple(false) - .help("") - ) - .arg(Arg::with_name("names") - .long("name") - .short("n") - .required(false) - .takes_value(true) - .multiple(true) - .help("") - ) - .arg(Arg::with_name("picture") - .long("picture") - .short("p") - .required(false) - .takes_value(true) - .multiple(false) - .help("IPFS hash of a picture which shall be associated with that profile") - ) - .arg(Arg::with_name("more") - .long("more") - .required(false) - .takes_value(true) - .multiple(true) - .help("More data to be associated with that profile. JSON blob assumed with {'key': {'mimetype':'<mimetype>','data':'<ipfshash>'}}") - ) - ) - .subcommand(SubCommand::with_name("create-block-blob") - .about("") - .version("0.1.0") - .arg(Arg::with_name("version") - .long("version") - .short("v") - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - .arg(Arg::with_name("parents") - .long("parent") - .short("p") - .required(false) - .takes_value(true) - .multiple(true) - .help("") - ) - .arg(Arg::with_name("content") - .long("content") - .short("c") - .required(true) - .takes_value(true) - .multiple(false) - .help("") - ) - ) - - // High-level commands - - .subcommand(SubCommand::with_name("create-profile") - .about("Create a new profile") - .version("0.1.0") - .arg(Arg::with_name("name") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("The name of the profile. Also the name of the IPFS Key used for this profile.") - ) - ) - - .subcommand(SubCommand::with_name("post") - .about("Write a new post") - .version("0.1.0") - .arg(Arg::with_name("profile-name") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("Name of the profile to post to") - ) - .arg(Arg::with_name("text") - .index(2) - .required(true) - .takes_value(true) - .multiple(false) - .help("Text to post") - ) - .arg(Arg::with_name("parents") - .index(3) - .required(true) - .takes_value(true) - .multiple(true) - .help("Parent block(s)") - ) - ) - - .subcommand(SubCommand::with_name("publish") - .about("Publish a block as latest block") - .version("0.1.0") - .arg(Arg::with_name("profile_name") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("Name of the Profile (IPFS Key)") - ) - .arg(Arg::with_name("blockhash") - .index(2) - .required(true) - .takes_value(true) - .multiple(false) - .help("Block to publish") - ) - ) - - .subcommand(SubCommand::with_name("get-profile-state") - .about("Get the latest block hash (IPFS Hash) for a profile") - .version("0.1.0") - .arg(Arg::with_name("profile_name") - .index(1) - .required(true) - .takes_value(true) - .multiple(false) - .help("Name of the Profile (IPFS Key)") - ) - ) - -} - - diff --git a/src/typeext/block.rs b/src/typeext/block.rs deleted file mode 100644 index 111e8c9..0000000 --- a/src/typeext/block.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::ops::Deref; - -use failure::Error; -use futures::Future; -use futures::stream; -use futures::stream::Stream; - -use crate::types::block::Block; -use crate::types::content::Content; -use crate::types::util::IPFSHash; -use crate::repository::Repository; - -/// Wrapper for Block type which holds a reference to the repository and is thus able to provide -/// convenient functionality out of the box -pub struct BlockExt { - block: Block, - repo: Repository, -} - -impl Into<Block> for BlockExt { - fn into(self) -> Block { - self.block - } -} - -impl Deref for BlockExt { - type Target = Block; - - fn deref(&self) -> &Self::Target { - &self.block - } -} - -impl BlockExt { - pub fn from_block(block: Block, repo: Repository) -> Self { - BlockExt { block, repo } - } - - pub fn parents(&self) -> impl Stream<Item = Result<BlockExt, Error>> { - stream::unfold((self.repo.clone(), self.block.parents().clone()), move |(repo, mut state)| { - async { - if let Some(hash) = state.pop() { - match repo.get_block(hash).await { - Ok(block) => { - Some((Ok(BlockExt::from_block(block, repo.clone())), (repo, state))) - }, - Err(e) => Some((Err(e), (repo, state))), - } - } else { - None - } - } - }) - } - - pub async fn content(&self) -> Result<Content, Error> { - self.repo.get_content(self.block.content().clone()).await - } -} diff --git a/src/typeext/mod.rs b/src/typeext/mod.rs deleted file mode 100644 index a863eaa..0000000 --- a/src/typeext/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod block; |