summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-12-08 17:50:29 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-12-08 18:44:24 +0100
commit7ae0325d7e54df8db88bc7bc757c3cb674a0fb0f (patch)
treed5aed5f5c9681c954f6756550ca219d48b1dee1a
parent82add278cc59329345c49554539922926635ee70 (diff)
Split codebase in subcrates for lib, cli and gui
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--Cargo.toml59
-rw-r--r--cli/Cargo.toml49
-rw-r--r--cli/src/cli.rs (renamed from src/cli.rs)0
-rw-r--r--cli/src/commands/mod.rs (renamed from src/commands/mod.rs)0
-rw-r--r--cli/src/commands/profile.rs (renamed from src/commands/profile.rs)4
-rw-r--r--cli/src/main.rs (renamed from src/main.rs)14
-rw-r--r--gui/Cargo.toml44
-rw-r--r--gui/src/cli.rs12
-rw-r--r--gui/src/gui/mod.rs (renamed from src/gui/mod.rs)6
-rw-r--r--gui/src/main.rs26
-rw-r--r--lib/Cargo.toml47
-rw-r--r--lib/src/cid.rs (renamed from src/cid.rs)0
-rw-r--r--lib/src/client.rs (renamed from src/client.rs)0
-rw-r--r--lib/src/config.rs (renamed from src/config.rs)0
-rw-r--r--lib/src/consts.rs (renamed from src/consts.rs)0
-rw-r--r--lib/src/ipfs_client.rs (renamed from src/ipfs_client.rs)0
-rw-r--r--lib/src/lib.rs6
-rw-r--r--lib/src/profile/mod.rs (renamed from src/profile/mod.rs)0
-rw-r--r--lib/src/profile/state.rs (renamed from src/profile/state.rs)0
-rw-r--r--lib/src/types/datetime.rs (renamed from src/types/datetime.rs)0
-rw-r--r--lib/src/types/mod.rs (renamed from src/types/mod.rs)0
-rw-r--r--lib/src/types/node.rs (renamed from src/types/node.rs)0
-rw-r--r--lib/src/types/payload.rs (renamed from src/types/payload.rs)0
23 files changed, 200 insertions, 67 deletions
diff --git a/Cargo.toml b/Cargo.toml
index d8a78c8..f0e2060 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,53 +1,6 @@
-[package]
-name = "distrox"
-version = "0.1.0"
-authors = ["Matthias Beyer <mail@beyermatthias.de>"]
-
-description = "Distributed network build on IPFS"
-
-keywords = ["social", "network", "ipfs", "distributed"]
-readme = "README.md"
-license = "GPL-2.0"
-
-documentation = "https://docs.rs/distrox"
-repository = "https://github.com/matthiasbeyer/distrox"
-homepage = "http://github.com/matthiasbeyer/distrox"
-
-edition = "2018"
-
-[dependencies]
-anyhow = "1"
-async-trait = "0.1"
-chrono = { version = "0.4", features = ["serde"] }
-cid = "0.5"
-clap = "3.0.0-beta.5"
-daglib = { git = "https://git.sr.ht/~matthiasbeyer/daglib", branch = "master" }
-env_logger = "0.8"
-futures = "0.3"
-log = "0.4"
-tokio = { version = "1", features = ["full", "rt", "macros"] }
-mime = "0.3"
-rand_core = { version = "0.6", features = ["getrandom"] }
-rand_os = "0.2"
-ed25519-dalek = "*"
-http = "0.2"
-serde = "1"
-serde_json = "1"
-getset = "0.1"
-xdg = "2.4"
-tracing = "0.1"
-ctrlc = "3.2"
-
-iced_native = "0.4.0"
-iced_wgpu = "0.4.0"
-
-[dependencies.ipfs]
-git = "https://github.com/rs-ipfs/rust-ipfs/"
-rev = "ad3ab49b4d9236363969b0f74f14aabc7c906b3b"
-
-[dependencies.iced]
-version = "0.3.0"
-features = ["glow", "tokio", "debug"]
-
-[dev-dependencies]
-multibase = "0.8"
+[workspace]
+members = [
+ "cli",
+ "gui",
+ "lib",
+]
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
new file mode 100644
index 0000000..e558c19
--- /dev/null
+++ b/cli/Cargo.toml
@@ -0,0 +1,49 @@
+[package]
+name = "distrox-cli"
+version = "0.1.0"
+authors = ["Matthias Beyer <mail@beyermatthias.de>"]
+
+description = "Distributed network build on IPFS, CLI frontend"
+
+keywords = ["social", "network", "ipfs", "distributed"]
+readme = "README.md"
+license = "GPL-2.0"
+
+documentation = "https://docs.rs/distrox"
+repository = "https://github.com/matthiasbeyer/distrox"
+homepage = "http://github.com/matthiasbeyer/distrox"
+
+edition = "2018"
+
+[dependencies]
+anyhow = "1"
+async-trait = "0.1"
+chrono = { version = "0.4", features = ["serde"] }
+cid = "0.5"
+clap = "3.0.0-beta.5"
+daglib = { git = "https://git.sr.ht/~matthiasbeyer/daglib", branch = "master" }
+env_logger = "0.8"
+futures = "0.3"
+log = "0.4"
+tokio = { version = "1", features = ["full", "rt", "macros"] }
+mime = "0.3"
+rand_core = { version = "0.6", features = ["getrandom"] }
+rand_os = "0.2"
+ed25519-dalek = "*"
+http = "0.2"
+serde = "1"
+serde_json = "1"
+getset = "0.1"
+xdg = "2.4"
+tracing = "0.1"
+ctrlc = "3.2"
+
+[dependencies.ipfs]
+git = "https://github.com/rs-ipfs/rust-ipfs/"
+rev = "ad3ab49b4d9236363969b0f74f14aabc7c906b3b"
+
+[dependencies.distrox-lib]
+path = "../lib"
+
+[dev-dependencies]
+multibase = "0.8"
diff --git a/src/cli.rs b/cli/src/cli.rs
index 3f74128..3f74128 100644
--- a/src/cli.rs
+++ b/cli/src/cli.rs
diff --git a/src/commands/mod.rs b/cli/src/commands/mod.rs
index 5569bcb..5569bcb 100644
--- a/src/commands/mod.rs
+++ b/cli/src/commands/mod.rs
diff --git a/src/commands/profile.rs b/cli/src/commands/profile.rs
index 853984f..0eb8b75 100644
--- a/src/commands/profile.rs
+++ b/cli/src/commands/profile.rs
@@ -6,8 +6,8 @@ use anyhow::Context;
use anyhow::Result;
use clap::ArgMatches;
-use crate::config::Config;
-use crate::profile::Profile;
+use distrox_lib::config::Config;
+use distrox_lib::profile::Profile;
pub async fn profile(matches: &ArgMatches) -> Result<()> {
match matches.subcommand() {
diff --git a/src/main.rs b/cli/src/main.rs
index 3caf1ae..fea466c 100644
--- a/src/main.rs
+++ b/cli/src/main.rs
@@ -1,14 +1,7 @@
use anyhow::Result;
-pub mod cli;
-pub mod client;
+mod cli;
mod commands;
-pub mod config;
-pub mod consts;
-pub mod ipfs_client;
-pub mod profile;
-pub mod types;
-mod gui;
fn main() -> Result<()> {
let _ = env_logger::try_init()?;
@@ -16,7 +9,9 @@ fn main() -> Result<()> {
match matches.subcommand() {
Some(("profile", matches)) => crate::commands::profile(matches).await,
- Some(("gui", _)) => crate::gui::run(),
+ Some(("gui", _)) => {
+ unimplemented!()
+ },
Some((other, _)) => {
log::error!("No subcommand {} implemented", other);
Ok(())
@@ -29,3 +24,4 @@ fn main() -> Result<()> {
}
}
+
diff --git a/gui/Cargo.toml b/gui/Cargo.toml
new file mode 100644
index 0000000..d1b7c6d
--- /dev/null
+++ b/gui/Cargo.toml
@@ -0,0 +1,44 @@
+[package]
+name = "distrox-gui"
+version = "0.1.0"
+authors = ["Matthias Beyer <mail@beyermatthias.de>"]
+
+description = "Distributed network build on IPFS, GUI frontend"
+
+keywords = ["social", "network", "ipfs", "distributed"]
+readme = "README.md"
+license = "GPL-2.0"
+
+documentation = "https://docs.rs/distrox"
+repository = "https://github.com/matthiasbeyer/distrox"
+homepage = "http://github.com/matthiasbeyer/distrox"
+
+edition = "2018"
+
+[dependencies]
+anyhow = "1"
+chrono = { version = "0.4", features = ["serde"] }
+cid = "0.5"
+clap = "3.0.0-beta.5"
+env_logger = "0.8"
+futures = "0.3"
+log = "0.4"
+getset = "0.1"
+xdg = "2.4"
+tracing = "0.1"
+ctrlc = "3.2"
+
+[dependencies.ipfs]
+git = "https://github.com/rs-ipfs/rust-ipfs/"
+rev = "ad3ab49b4d9236363969b0f74f14aabc7c906b3b"
+
+[dependencies.iced]
+version = "0.3.0"
+features = ["glow", "tokio", "debug"]
+
+[dependencies.distrox-lib]
+path = "../lib"
+
+[dev-dependencies]
+multibase = "0.8"
+
diff --git a/gui/src/cli.rs b/gui/src/cli.rs
new file mode 100644
index 0000000..6ebdfb9
--- /dev/null
+++ b/gui/src/cli.rs
@@ -0,0 +1,12 @@
+use clap::crate_authors;
+use clap::crate_version;
+use clap::App;
+use clap::Arg;
+
+pub fn app<'a>() -> App<'a> {
+ App::new("distrox-gui")
+ .author(crate_authors!())
+ .version(crate_version!())
+ .about("Distributed social network, GUI frontend")
+}
+
diff --git a/src/gui/mod.rs b/gui/src/gui/mod.rs
index 503ed9e..2eb936e 100644
--- a/src/gui/mod.rs
+++ b/gui/src/gui/mod.rs
@@ -11,9 +11,9 @@ use iced::TextInput;
use iced::scrollable;
use iced::text_input;
-use crate::profile::Profile;
-use crate::config::Config;
-use crate::ipfs_client::IpfsClient;
+use distrox_lib::profile::Profile;
+use distrox_lib::config::Config;
+use distrox_lib::ipfs_client::IpfsClient;
#[derive(Debug)]
enum Distrox {
diff --git a/gui/src/main.rs b/gui/src/main.rs
new file mode 100644
index 0000000..ea47a93
--- /dev/null
+++ b/gui/src/main.rs
@@ -0,0 +1,26 @@
+use anyhow::Result;
+
+mod cli;
+mod gui;
+
+use distrox_lib::*;
+
+fn main() -> Result<()> {
+ let _ = env_logger::try_init()?;
+ let matches = crate::cli::app().get_matches();
+
+ match matches.subcommand() {
+ None => crate::gui::run(),
+ Some((other, _)) => {
+ log::error!("No subcommand {} implemented", other);
+ Ok(())
+ },
+
+ _ => {
+ log::error!("Don't know what to do");
+ Ok(())
+ },
+ }
+}
+
+
diff --git a/lib/Cargo.toml b/lib/Cargo.toml
new file mode 100644
index 0000000..0655384
--- /dev/null
+++ b/lib/Cargo.toml
@@ -0,0 +1,47 @@
+[package]
+name = "distrox-lib"
+version = "0.1.0"
+authors = ["Matthias Beyer <mail@beyermatthias.de>"]
+
+description = "Distributed network build on IPFS"
+
+keywords = ["social", "network", "ipfs", "distributed"]
+readme = "README.md"
+license = "GPL-2.0"
+
+documentation = "https://docs.rs/distrox"
+repository = "https://github.com/matthiasbeyer/distrox"
+homepage = "http://github.com/matthiasbeyer/distrox"
+
+edition = "2018"
+
+[dependencies]
+anyhow = "1"
+async-trait = "0.1"
+chrono = { version = "0.4", features = ["serde"] }
+cid = "0.5"
+clap = "3.0.0-beta.5"
+daglib = { git = "https://git.sr.ht/~matthiasbeyer/daglib", branch = "master" }
+env_logger = "0.8"
+futures = "0.3"
+log = "0.4"
+tokio = { version = "1", features = ["full", "rt", "macros"] }
+mime = "0.3"
+rand_core = { version = "0.6", features = ["getrandom"] }
+rand_os = "0.2"
+ed25519-dalek = "*"
+http = "0.2"
+serde = "1"
+serde_json = "1"
+getset = "0.1"
+xdg = "2.4"
+tracing = "0.1"
+ctrlc = "3.2"
+libp2p = "0.39.0"
+
+[dependencies.ipfs]
+git = "https://github.com/rs-ipfs/rust-ipfs/"
+rev = "ad3ab49b4d9236363969b0f74f14aabc7c906b3b"
+
+[dev-dependencies]
+multibase = "0.8"
diff --git a/src/cid.rs b/lib/src/cid.rs
index 2957cc5..2957cc5 100644
--- a/src/cid.rs
+++ b/lib/src/cid.rs
diff --git a/src/client.rs b/lib/src/client.rs
index bb280a5..bb280a5 100644
--- a/src/client.rs
+++ b/lib/src/client.rs
diff --git a/src/config.rs b/lib/src/config.rs
index 0d25e78..0d25e78 100644
--- a/src/config.rs
+++ b/lib/src/config.rs
diff --git a/src/consts.rs b/lib/src/consts.rs
index 79ff2f5..79ff2f5 100644
--- a/src/consts.rs
+++ b/lib/src/consts.rs
diff --git a/src/ipfs_client.rs b/lib/src/ipfs_client.rs
index 964b22c..964b22c 100644
--- a/src/ipfs_client.rs
+++ b/lib/src/ipfs_client.rs
diff --git a/lib/src/lib.rs b/lib/src/lib.rs
new file mode 100644
index 0000000..759ea14
--- /dev/null
+++ b/lib/src/lib.rs
@@ -0,0 +1,6 @@
+pub mod client;
+pub mod config;
+pub mod consts;
+pub mod ipfs_client;
+pub mod profile;
+pub mod types;
diff --git a/src/profile/mod.rs b/lib/src/profile/mod.rs
index e3ce175..e3ce175 100644
--- a/src/profile/mod.rs
+++ b/lib/src/profile/mod.rs
diff --git a/src/profile/state.rs b/lib/src/profile/state.rs
index 4075b52..4075b52 100644
--- a/src/profile/state.rs
+++ b/lib/src/profile/state.rs
diff --git a/src/types/datetime.rs b/lib/src/types/datetime.rs
index 00d739a..00d739a 100644
--- a/src/types/datetime.rs
+++ b/lib/src/types/datetime.rs
diff --git a/src/types/mod.rs b/lib/src/types/mod.rs
index 7382f16..7382f16 100644
--- a/src/types/mod.rs
+++ b/lib/src/types/mod.rs
diff --git a/src/types/node.rs b/lib/src/types/node.rs
index eb5679b..eb5679b 100644
--- a/src/types/node.rs
+++ b/lib/src/types/node.rs
diff --git a/src/types/payload.rs b/lib/src/types/payload.rs
index a11b215..a11b215 100644
--- a/src/types/payload.rs
+++ b/lib/src/types/payload.rs