aboutsummaryrefslogtreecommitdiffstats
path: root/examples/zot.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-10-08 13:48:11 +0200
committerHarald Eilertsen <haraldei@anduin.net>2018-10-08 13:48:11 +0200
commitfc7735d33a562f71729e96514b722db7d6f55f05 (patch)
tree511c50eb789d0628191de6af2c46b75f016c27f9 /examples/zot.rs
parent8d20318f22fa0344fa8804e15263b7736c6eff15 (diff)
downloadrust-zotapi-fc7735d33a562f71729e96514b722db7d6f55f05.tar.gz
rust-zotapi-fc7735d33a562f71729e96514b722db7d6f55f05.tar.bz2
rust-zotapi-fc7735d33a562f71729e96514b722db7d6f55f05.zip
Add fetching network_stream to main example.
This duplicates a lot of the code from the channel_stream example, will try to refactor later.
Diffstat (limited to 'examples/zot.rs')
-rw-r--r--examples/zot.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/examples/zot.rs b/examples/zot.rs
index a0d930e..2c49fe3 100644
--- a/examples/zot.rs
+++ b/examples/zot.rs
@@ -26,6 +26,7 @@ use dotenv::dotenv;
use std::env;
mod channel_stream;
+mod network_stream;
fn main() {
dotenv().ok();
@@ -40,12 +41,24 @@ fn main() {
.arg(Arg::with_name("raw")
.long("raw")
.help("Display raw json payload")))
+ .subcommand(
+ SubCommand::with_name("network-stream")
+ .about("Fetch the network stream")
+ .arg(Arg::with_name("raw")
+ .long("raw")
+ .help("Display raw json payload")))
.get_matches();
+ let client = zotapi::client(&site, &user, &password);
+
match matches.subcommand() {
("channel-stream", Some(m)) => {
let raw = m.is_present("raw");
- channel_stream::fetch(&zotapi::client(&site, &user, &password), raw);
+ channel_stream::fetch(&client, raw);
+ },
+ ("network-stream", Some(m)) => {
+ let raw = m.is_present("raw");
+ network_stream::fetch(&client, raw);
},
_ => {
println!("{}", matches.usage());