// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // rustpkg - a purely function package manager and build system #[link(name = "rustpkg", vers = "0.6", uuid = "25de5e6e-279e-4a20-845c-4cabae92daaf", url = "https://github.com/mozilla/rust/tree/master/src/librustpkg")]; #[crate_type = "lib"]; #[no_core]; extern mod core(vers = "0.6"); extern mod std(vers = "0.6"); extern mod rustc(vers = "0.6"); extern mod syntax(vers = "0.6"); use core::*; use std::getopts; use getopts::{optflag, optopt, opt_present}; use rustc::metadata::{filesearch}; mod api; mod usage; mod util; use util::*; pub fn main() { let args = os::args(); let opts = ~[optflag(~"h"), optflag(~"help")]; let matches = &match getopts::getopts(args, opts) { result::Ok(m) => m, result::Err(f) => { fail fmt!("%s", getopts::fail_str(f)); } }; let help = opt_present(matches, ~"h") || opt_present(matches, ~"help"); let mut args = copy matches.free; args.shift(); if (args.len() < 1) { return usage::general(); } let cmd = copy args[0]; if !is_cmd(cmd) { return usage::general(); } else if help { match cmd { ~"build" => usage::build(), ~"clean" => usage::clean(), ~"install" => usage::install(), ~"prefer" => usage::prefer(), ~"test" => usage::test(), ~"uninstall" => usage::uninstall(), ~"unprefer" => usage::unprefer(), _ => usage::general() } } Ctx { cmd: cmd, args: args } } pub use Crate = api::Crate; pub use build = api::build; pub use util = api::util;