extern crate clap;
extern crate regex;
extern crate reqwest;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
use std::process;
mod api;
mod cmd;
mod credentials;
mod error;
use error::{DokError, DokResult};
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
const AUTHORS: &'static str = env!("CARGO_PKG_AUTHORS");
fn main() {
let matches = clap::App::new("dok")
.version(VERSION)
.author(AUTHORS)
.subcommand(clap::SubCommand::with_name("list")
.alias("ls")
.about("List images in a registry or registry subpath")
.arg(clap::Arg::with_name("REGISTRY")
.help("Registry to list images for")
.required(true)))
.subcommand(clap::SubCommand::with_name("tags")
.about("List tags for a given image")
.arg(clap::Arg::with_name("IMAGE")
.help("Image to list tags for")
.required(true)))
.setting(clap::AppSettings::DeriveDisplayOrder)
.setting(clap::AppSettings::SubcommandRequiredElseHelp)
.get_matches();
let result = match matches.subcommand() {
("list", Some(sub_matches)) => cmd::list(sub_matches),
("tags", Some(sub_matches)) => cmd::tags(sub_matches),
_ => Ok(()),
};
if let Err(e) = result {
println!("{}", e);
process::exit(1);
}
}