]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #9236 : steveklabnik/rust/rustpkg_init, r=catamorphism
authorbors <bors@rust-lang.org>
Tue, 17 Sep 2013 18:00:46 +0000 (11:00 -0700)
committerbors <bors@rust-lang.org>
Tue, 17 Sep 2013 18:00:46 +0000 (11:00 -0700)
Closes #9045

Built on top of #9235, which isn't strictly needed for now, but I imagine I will use part of. Unsure.

I mostly wanted to start this off to get some feedback from @catamorphism and others. These are the directories that actually need made, but I was thinking about adding a few other things:

1. an `examples` directory, since it seems like that's a common pattern
2. a `.gitignore` file that ignores `build`. And anything else that makes sense
3. a sample module that'd actually compile

Feedback?

src/librustpkg/rustpkg.rs
src/librustpkg/usage.rs
src/librustpkg/util.rs

index eef1dcabfd0efd1c397981401b58135cb65227b3..2a0cf5fea34fa6aa83887ad55aeb610dd2b08d64 100644 (file)
@@ -189,6 +189,7 @@ fn install_no_build(&self,
     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 @@ fn run(&self, cmd: &str, args: ~[~str]) {
             "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 @@ fn test(&self)  {
         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()
index dae949541b3a185a3272a7d9ba74db586ecafb35..c0601818f3772793a6ea3820166291923ca1fd0e 100644 (file)
@@ -148,3 +148,10 @@ pub fn test() {
 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.
+");
+}
index 71c4760f28d9e61dcb71c45e3435018697f84a9c..ab883b50f8c68e5ec6c69c3f58774d244ea34cc8 100644 (file)
@@ -33,7 +33,7 @@
 // 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"];