about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2013-09-16 14:59:34 -0700
committerSteve Klabnik <steve@steveklabnik.com>2013-09-17 10:53:32 -0700
commit77bbf23b4a6782b3e460c7eea339b858d98ae676 (patch)
tree01441422a0536cdfd59bd844e1feaaea294b6932
parent0ec4d34b3f0fa1897ace96475a32ff0c8e15b33b (diff)
downloadrust-77bbf23b4a6782b3e460c7eea339b858d98ae676.tar.gz
rust-77bbf23b4a6782b3e460c7eea339b858d98ae676.zip
Implementing 'rustpkg init'.
This will initialize a new workspace.
-rw-r--r--src/librustpkg/rustpkg.rs16
-rw-r--r--src/librustpkg/usage.rs7
-rw-r--r--src/librustpkg/util.rs2
3 files changed, 24 insertions, 1 deletions
diff --git a/src/librustpkg/rustpkg.rs b/src/librustpkg/rustpkg.rs
index eef1dcabfd0..2a0cf5fea34 100644
--- a/src/librustpkg/rustpkg.rs
+++ b/src/librustpkg/rustpkg.rs
@@ -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 {
@@ -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();
@@ -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");
     }
@@ -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()
diff --git a/src/librustpkg/usage.rs b/src/librustpkg/usage.rs
index dae949541b3..c0601818f37 100644
--- a/src/librustpkg/usage.rs
+++ b/src/librustpkg/usage.rs
@@ -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.
+");
+}
diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs
index 71c4760f28d..ab883b50f8c 100644
--- a/src/librustpkg/util.rs
+++ b/src/librustpkg/util.rs
@@ -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"];