aboutsummaryrefslogtreecommitdiffstats
path: root/examples/zotcli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/zotcli.rs')
-rw-r--r--examples/zotcli.rs53
1 files changed, 19 insertions, 34 deletions
diff --git a/examples/zotcli.rs b/examples/zotcli.rs
index 2b068e0..14bb9ad 100644
--- a/examples/zotcli.rs
+++ b/examples/zotcli.rs
@@ -15,13 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use clap::{
- clap_app,
- crate_name,
- crate_version,
- crate_authors,
- crate_description,
-};
+use clap::{clap_app, crate_authors, crate_description, crate_name, crate_version};
use dotenv::dotenv;
use std::env;
use std::str::FromStr;
@@ -86,75 +80,66 @@ fn main() {
("channel", Some(m)) => {
let raw = m.is_present("raw");
zot::channel_stream::fetch(&client, raw);
- },
+ }
("network", Some(m)) => {
let raw = m.is_present("raw");
zot::network_stream::fetch(&client, raw);
- },
+ }
("abconfig", _) => {
zot::abconfig::fetch(&client);
- },
+ }
("abook", Some(m)) => {
let raw = m.is_present("raw");
zot::abook::fetch(&client, raw);
- },
+ }
("group", Some(m)) => {
if let Some(id) = m.value_of("ID") {
let res = client
.group_members()
.by_group_id(u64::from_str(id).unwrap())
- .fetch().unwrap();
+ .fetch()
+ .unwrap();
if m.is_present("raw") {
println!("{}", res);
- }
- else {
+ } else {
zot::group::list_members(&res);
}
- }
- else if let Some(gname) = m.value_of("GNAME") {
- let res = client
- .group_members()
- .by_group_name(gname)
- .fetch().unwrap();
+ } else if let Some(gname) = m.value_of("GNAME") {
+ let res = client.group_members().by_group_name(gname).fetch().unwrap();
if m.is_present("raw") {
println!("{}", res);
- }
- else {
+ } else {
zot::group::list_members(&res);
}
- }
- else {
+ } else {
let res = client.group().fetch().unwrap();
if m.is_present("raw") {
println!("{}", res);
- }
- else {
+ } else {
zot::group::list(&res);
}
}
- },
+ }
("xchan", Some(m)) => {
let raw = m.is_present("raw");
let t = if m.is_present("guid") {
zot::xchan::Type::GUID
- }
- else if m.is_present("hash") {
+ } else if m.is_present("hash") {
zot::xchan::Type::Hash
- }
- else {
+ } else {
zot::xchan::Type::Addr
};
zot::xchan::fetch(&client, raw, t, m.value_of("ID").unwrap());
- },
+ }
("post", Some(m)) => {
zot::item::post(&client, m);
- },
+ }
_ => {
println!("{}", matches.usage());
- },
+ }
}
}