diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2023-03-26 14:14:52 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2023-03-26 14:14:52 +0200 |
commit | 3cc87b45f70ae32fe8ca69b3cd185dd8d56d94dd (patch) | |
tree | cbc0b84d6668de545c623834727665cbb08902ba /src/bin/zot/main.rs | |
parent | d08138ea633da76d9ca390e4f9e3c5489aee23d1 (diff) | |
download | rust-zotapi-3cc87b45f70ae32fe8ca69b3cd185dd8d56d94dd.tar.gz rust-zotapi-3cc87b45f70ae32fe8ca69b3cd185dd8d56d94dd.tar.bz2 rust-zotapi-3cc87b45f70ae32fe8ca69b3cd185dd8d56d94dd.zip |
Fetch abook and xchan directly from api.
We don't really need the intermediate layer in the binary module.
Diffstat (limited to 'src/bin/zot/main.rs')
-rw-r--r-- | src/bin/zot/main.rs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/bin/zot/main.rs b/src/bin/zot/main.rs index 09fdd61..f2caac4 100644 --- a/src/bin/zot/main.rs +++ b/src/bin/zot/main.rs @@ -90,8 +90,13 @@ async fn main() { zot::abconfig::fetch(&client).await; } ("abook", Some(m)) => { - let raw = m.is_present("raw"); - zot::abook::fetch(&client, raw).await; + let r = zotapi::Abook::z(); + + if m.is_present("raw") { + println!("{}", r.fetch_raw(&client).await.unwrap()); + } else { + println!("{:?}", r.fetch(&client).await); + } } ("group", Some(m)) => { if let Some(id) = m.value_of("ID") { @@ -129,16 +134,22 @@ async fn main() { } } ("xchan", Some(m)) => { - let raw = m.is_present("raw"); - let t = if m.is_present("guid") { - zot::xchan::Type::GUID + let mut r = zotapi::XChan::z(); + let id = m.value_of("ID").expect("No xchan provided."); + + if m.is_present("guid") { + r.by_guid(id) } else if m.is_present("hash") { - zot::xchan::Type::Hash + r.by_hash(id) } else { - zot::xchan::Type::Addr + r.by_address(id) }; - zot::xchan::fetch(&client, raw, t, m.value_of("ID").unwrap()).await; + if m.is_present("raw") { + println!("{}", r.fetch_raw(&client).await.unwrap()); + } else { + println!("{:?}", r.fetch(&client).await); + } } ("post", Some(m)) => { zot::item::post(&client, m).await; |