1
Fork 0

rustpkg: Finish parsing package scripts and finish boilerplate

This commit is contained in:
Zack Corr 2013-01-17 19:05:19 +10:00 committed by Graydon Hoare
parent 226b61ba5f
commit 220144b93c
2 changed files with 285 additions and 29 deletions

View file

@ -1,7 +1,7 @@
use core::*;
use rustc::metadata::filesearch;
use semver::Version;
use std::net::url;
use std::term;
pub fn root() -> Path {
match filesearch::get_rustpkg_root() {
@ -40,6 +40,46 @@ pub fn parse_vers(vers: ~str) -> Version {
}
}
pub fn need_dir(s: &Path) {
if !os::path_is_dir(s) && !os::make_dir(s, 493_i32) {
fail fmt!("can't create dir: %s", s.to_str());
}
}
pub fn info(msg: ~str) {
let out = io::stdout();
if term::color_supported() {
term::fg(out, term::color_green);
out.write_str(~"info: ");
term::reset(out);
out.write_line(msg);
} else { out.write_line(~"info: " + msg); }
}
pub fn warn(msg: ~str) {
let out = io::stdout();
if term::color_supported() {
term::fg(out, term::color_yellow);
out.write_str(~"warning: ");
term::reset(out);
out.write_line(msg);
}else { out.write_line(~"warning: " + msg); }
}
pub fn error(msg: ~str) {
let out = io::stdout();
if term::color_supported() {
term::fg(out, term::color_red);
out.write_str(~"error: ");
term::reset(out);
out.write_line(msg);
}
else { out.write_line(~"error: " + msg); }
}
#[test]
fn test_is_cmd() {
assert is_cmd(~"build");