mozilla/rust — pull request #10651 by mrordinaire (2013-11-25 09:14:01+00:00)
Title: more useful rustpkg init

This PR modifies the behavior of `rustpkg init`.

`rustpkg init` now accepts two more arguments, the first is the type of package to initialize (`bin` or `lib`), and the second is the package name. Instead of initializing a workspace in the current directory, `rustpkg init` now initializes a workspace under the directory with the same name as the supplied package name. In addition, it also creates some default crates (e.g. `lib.rs` and `test.rs`) under `src//`.

E.g. `rustpkg init lib awesome_lib` will create the following directory tree in the current directory.

awesome_lib/
- bin/
- build/
- lib/
- src/
- awesome_lib/
- lib.rs
- test.rs

The content of `lib.rs` is the following.
```rust
pub fn get_answer() -> int {
42
}
```

The content of `test.rs` is the following.
```rust
mod lib;

#[test]
fn test_smoke_test() {
assert_eq!(lib::get_answer(), 42);
}
```