#![deny(warnings)]
#![feature(core, path)]
extern crate git2;
extern crate docopt;
extern crate "rustc-serialize" as rustc_serialize;
use docopt::Docopt;
use git2::{Repository, Direction};
#[derive(RustcDecodable)]
struct Args {
arg_remote: String,
}
fn run(args: &Args) -> Result<(), git2::Error> {
let repo = try!(Repository::open(&Path::new(".")));
let remote = args.arg_remote.as_slice();
let mut remote = try!(repo.find_remote(remote).or_else(|_| {
repo.remote_anonymous(remote, None)
}));
try!(remote.connect(Direction::Fetch));
for head in try!(remote.list()).iter() {
println!("{}\t{}", head.oid(), head.name());
}
Ok(())
}
fn main() {
const USAGE: &'static str = "
usage: ls-remote [option] <remote>
Options:
-h, --help show this message
";
let args = Docopt::new(USAGE).and_then(|d| d.decode())
.unwrap_or_else(|e| e.exit());
match run(&args) {
Ok(()) => {}
Err(e) => println!("error: {}", e),
}
}