mirror of
https://git.alemi.dev/fedicharter.git
synced 2024-11-22 16:34:49 +01:00
feat: separated lib and cli behind features
This commit is contained in:
parent
86dbf15f01
commit
ac20d43b20
4 changed files with 42 additions and 21 deletions
36
Cargo.toml
36
Cargo.toml
|
@ -7,22 +7,38 @@ repository = "https://github.com/alemidev/fedicharter"
|
|||
readme = "README.md"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
name = "fedicharter"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "fedicharter-cli"
|
||||
path = "src/cli/main.rs"
|
||||
required-features = ["cli"]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
async-recursion = "1.0.5"
|
||||
axum = "0.6.20"
|
||||
chrono = "0.4.31"
|
||||
clap = { version = "4.4.6", features = ["derive"] }
|
||||
thiserror = "1.0.49"
|
||||
derive_more = "0.99.17"
|
||||
lazy_static = "1.4.0"
|
||||
# nodeinfo = { git = "https://codeberg.org/thefederationinfo/nodeinfo-rs.git" }
|
||||
reqwest = { version = "0.11.20", features = ["json"] }
|
||||
sea-orm = { version = "0.12.3", features = ["runtime-tokio-native-tls", "sqlx-sqlite", "sqlx-postgres"] }
|
||||
serde = { version = "1.0.188", features = ["derive"] }
|
||||
serde_json = "1.0.107"
|
||||
thiserror = "1.0.49"
|
||||
tokio = { version = "1.32.0", features = ["full"] }
|
||||
tracing = "0.1.37"
|
||||
tracing-subscriber = "0.3.17"
|
||||
tracing = "0.1.37" # TODO either this or log
|
||||
log = "0.4.20" # TODO either this or tracing
|
||||
#nodeinfo = { git = "https://codeberg.org/thefederationinfo/nodeinfo-rs.git" }
|
||||
|
||||
# async runtime and cli stuff
|
||||
tokio = { version = "1.32.0", features = ["full"], optional = true }
|
||||
tracing-subscriber = { version = "0.3.17", optional = true }
|
||||
axum = { version = "0.6.20", optional = true }
|
||||
reqwest = { version = "0.11.20", features = ["json"], optional = true }
|
||||
sea-orm = { version = "0.12.3", features = ["runtime-tokio-native-tls", "sqlx-sqlite", "sqlx-postgres"], optional = true }
|
||||
clap = { version = "4.4.6", features = ["derive"], optional = true }
|
||||
|
||||
|
||||
[features]
|
||||
default = ["web", "cli"]
|
||||
db = ["dep:tokio", "dep:sea-orm", "dep:reqwest"]
|
||||
cli = ["db", "dep:axum", "dep:tracing-subscriber", "dep:clap"]
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
use std::net::SocketAddr;
|
||||
|
||||
use crawl::collector::CollectorHandle;
|
||||
use fedicharter::crawl::collector::CollectorHandle;
|
||||
use sea_orm::Database;
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use tracing_subscriber::{prelude::*, filter::{LevelFilter, filter_fn}};
|
||||
|
||||
mod nodeinfo; // TODO this should me PRd into upstream
|
||||
|
||||
mod entities;
|
||||
|
||||
mod crawl;
|
||||
mod serve;
|
||||
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
/// an API crawling akkoma bubble instances network and creating a map
|
||||
struct CliArgs {
|
||||
|
@ -79,12 +71,12 @@ async fn main() {
|
|||
Some(host) => host.parse().expect("could not parse provided host"),
|
||||
None => SocketAddr::from(([127, 0, 0, 1], 18811)),
|
||||
};
|
||||
crate::serve::api_routes(addr, db).await;
|
||||
fedicharter::serve::api_routes(addr, db).await;
|
||||
},
|
||||
|
||||
CliAction::Crawl { mode: CliCrawlMode::Bubble { domain } } => {
|
||||
let collector = CollectorHandle::new(db).await;
|
||||
crate::crawl::bubble(&domain, collector).await.expect("network error wtf");
|
||||
fedicharter::crawl::bubble(&domain, collector).await.expect("network error wtf");
|
||||
},
|
||||
}
|
||||
}
|
10
src/lib.rs
Normal file
10
src/lib.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
pub mod nodeinfo; // TODO this should me PRd into upstream
|
||||
|
||||
#[cfg(feature = "db")]
|
||||
pub mod entities;
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
pub mod crawl;
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
pub mod serve;
|
|
@ -1,4 +1,7 @@
|
|||
pub mod model;
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
pub mod fetcher;
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
pub use fetcher::fetch_node_info as fetch;
|
||||
|
|
Loading…
Reference in a new issue