aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml2
-rw-r--r--examples/zotcli.rs94
2 files changed, 38 insertions, 58 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 4a6d634..c8115e0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,7 +26,7 @@ serde = "1.0"
serde_urlencoded = "0.5.1"
[dev-dependencies]
-clap = "2.32.0"
+clap = "2.33.0"
dotenv = "0.13"
mockito = "0.14"
serde_json = "1.0"
diff --git a/examples/zotcli.rs b/examples/zotcli.rs
index 672e3ef..565d3ff 100644
--- a/examples/zotcli.rs
+++ b/examples/zotcli.rs
@@ -15,19 +15,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-extern crate zotapi;
-extern crate dotenv;
-extern crate clap;
-extern crate serde_json;
-
use clap::{
- Arg,
- app_from_crate,
+ clap_app,
crate_name,
crate_version,
crate_authors,
crate_description,
- SubCommand
};
use dotenv::dotenv;
use std::env;
@@ -40,62 +33,49 @@ fn main() {
let user = env::var("HZ_USER").expect("USER variable expected");
let password = env::var("HZ_PASSWORD").expect("PASSWORD variable expected");
- let matches = app_from_crate!()
- .subcommand(
- SubCommand::with_name("channel-stream")
- .about("Fetch the channel stream")
- .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")))
- .subcommand(
- SubCommand::with_name("abook")
- .about("Fetch address book/contact info")
- .arg(Arg::with_name("raw")
- .long("raw")
- .help("Display raw json payload")))
- .subcommand(
- SubCommand::with_name("abconfig")
- .about("Fetch abconfig"))
- .subcommand(
- SubCommand::with_name("xchan")
- .about("Fetch xchan info")
- .arg(Arg::with_name("raw")
- .long("raw")
- .help("Display raw json payload"))
- .arg(Arg::with_name("addr")
- .long("addr")
- .help("ID is given as a webbie address (default)"))
- .arg(Arg::with_name("hash")
- .long("hash")
- .help("ID is given as a xchan hash"))
- .arg(Arg::with_name("guid")
- .long("guid")
- .help("ID is given as a GUID"))
- .arg(Arg::with_name("ID")
- .help("id (email, hash or GUID) of xchan to fetch")
- .required(true)))
- .subcommand(
- SubCommand::with_name("post")
- .about("Post a new message")
- .arg(Arg::with_name("BODY")
- .help("body of message")
- .required(true)))
- .get_matches();
+ let matches = clap_app!(app =>
+ (name: crate_name!())
+ (version: crate_version!())
+ (author: crate_authors!())
+ (about: crate_description!())
+ (@subcommand channel =>
+ (about: "Fetch the channel stream")
+ (@arg raw: --raw "Display raw json payload")
+ )
+ (@subcommand network =>
+ (about: "Fetch the network stream")
+ (@arg raw: --raw "Display raw json payload")
+ )
+ (@subcommand abook =>
+ (about: "Fetch address book/contact info")
+ (@arg raw: --raw "Display raw json payload")
+ )
+ (@subcommand abconfig =>
+ (about: "Fetch abconfig")
+ )
+ (@subcommand xchan =>
+ (about: "Fetch xchan info")
+ (@arg raw: --raw "Display raw json payload")
+ (@arg addr: --addr "ID is given as webbie (default)")
+ (@arg hash: --hash "ID is given as xchan hash")
+ (@arg guid: --guid "ID is given as a GUID")
+ (@arg ID: +required "id (webbie, hash or GUID) of xchan to fetch")
+ )
+ (@subcommand post =>
+ (about: "Post a new message")
+ (@arg BODY: +required "Body of the message")
+ )
+ )
+ .get_matches();
let client = zotapi::client(&site, &user, &password);
match matches.subcommand() {
- ("channel-stream", Some(m)) => {
+ ("channel", Some(m)) => {
let raw = m.is_present("raw");
zot::channel_stream::fetch(&client, raw);
},
- ("network-stream", Some(m)) => {
+ ("network", Some(m)) => {
let raw = m.is_present("raw");
zot::network_stream::fetch(&client, raw);
},