Skip to content

Commit

Permalink
Implementing 'rustpkg init'.
Browse files Browse the repository at this point in the history
This will initialize a new workspace.
  • Loading branch information
steveklabnik committed Sep 17, 2013
1 parent 0ec4d34 commit 77bbf23
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/librustpkg/rustpkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ pub trait CtxMethods {
fn test(&self);
fn uninstall(&self, _id: &str, _vers: Option<~str>);
fn unprefer(&self, _id: &str, _vers: Option<~str>);
fn init(&self);
}

impl CtxMethods for BuildContext {
Expand Down Expand Up @@ -319,6 +320,13 @@ impl CtxMethods for BuildContext {
"test" => {
self.test();
}
"init" => {
if args.len() != 0 {
return usage::init();
} else {
self.init();
}
}
"uninstall" => {
if args.len() < 1 {
return usage::uninstall();
Expand Down Expand Up @@ -540,6 +548,13 @@ impl CtxMethods for BuildContext {
fail!("test not yet implemented");
}

fn init(&self) {
os::mkdir_recursive(&Path("src"), U_RWX);
os::mkdir_recursive(&Path("lib"), U_RWX);
os::mkdir_recursive(&Path("bin"), U_RWX);
os::mkdir_recursive(&Path("build"), U_RWX);
}

fn uninstall(&self, _id: &str, _vers: Option<~str>) {
fail!("uninstall not yet implemented");
}
Expand Down Expand Up @@ -688,6 +703,7 @@ pub fn main_args(args: &[~str]) {
~"list" => usage::list(),
~"prefer" => usage::prefer(),
~"test" => usage::test(),
~"init" => usage::init(),
~"uninstall" => usage::uninstall(),
~"unprefer" => usage::unprefer(),
_ => usage::general()
Expand Down
7 changes: 7 additions & 0 deletions src/librustpkg/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,10 @@ and exit code will be redirected.
Options:
-c, --cfg Pass a cfg flag to the package script");
}

pub fn init() {
io::println("rustpkg init name
This makes a new workspace for working on a project named name.
");
}
2 changes: 1 addition & 1 deletion src/librustpkg/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use workcache_support::{digest_file_with_date, digest_only_date};
// you could update the match in rustpkg.rc but forget to update this list. I think
// that should be fixed.
static COMMANDS: &'static [&'static str] =
&["build", "clean", "do", "info", "install", "list", "prefer", "test", "uninstall",
&["build", "clean", "do", "info", "init", "install", "list", "prefer", "test", "uninstall",
"unprefer"];


Expand Down

2 comments on commit 77bbf23

@catamorphism
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ 🐐

@steveklabnik
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎊

Please sign in to comment.