]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
c34b1796 AL |
11 | #![deny(warnings)] |
12 | ||
62682a34 | 13 | #![feature(iter_arith)] |
c34b1796 | 14 | #![feature(path_relative_from)] |
62682a34 SL |
15 | #![feature(rustc_private)] |
16 | #![feature(rustdoc)] | |
1a4d82fc JJ |
17 | |
18 | extern crate rustdoc; | |
c34b1796 | 19 | extern crate rustc_back; |
1a4d82fc | 20 | |
85aaf69f | 21 | use std::env; |
c34b1796 | 22 | use std::error::Error; |
62682a34 SL |
23 | use std::process; |
24 | use std::sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT, Ordering}; | |
1a4d82fc JJ |
25 | use subcommand::Subcommand; |
26 | use term::Term; | |
27 | ||
1a4d82fc JJ |
28 | mod term; |
29 | mod error; | |
30 | mod book; | |
31 | ||
32 | mod subcommand; | |
33 | mod help; | |
34 | mod build; | |
35 | mod serve; | |
36 | mod test; | |
37 | ||
85aaf69f | 38 | mod javascript; |
1a4d82fc | 39 | |
62682a34 SL |
40 | static EXIT_STATUS: AtomicIsize = ATOMIC_ISIZE_INIT; |
41 | ||
1a4d82fc JJ |
42 | #[cfg(not(test))] // thanks #12327 |
43 | fn main() { | |
44 | let mut term = Term::new(); | |
85aaf69f | 45 | let cmd: Vec<_> = env::args().collect(); |
1a4d82fc | 46 | |
85aaf69f | 47 | if cmd.len() <= 1 { |
1a4d82fc JJ |
48 | help::usage() |
49 | } else { | |
c34b1796 | 50 | match subcommand::parse_name(&cmd[1][..]) { |
1a4d82fc | 51 | Some(mut subcmd) => { |
c34b1796 | 52 | match subcmd.parse_args(&cmd[..cmd.len()-1]) { |
1a4d82fc JJ |
53 | Ok(_) => { |
54 | match subcmd.execute(&mut term) { | |
55 | Ok(_) => (), | |
85aaf69f | 56 | Err(err) => { |
c34b1796 | 57 | term.err(&format!("error: {}", err)); |
85aaf69f | 58 | } |
1a4d82fc JJ |
59 | } |
60 | } | |
61 | Err(err) => { | |
62 | println!("{}", err.description()); | |
63 | println!(""); | |
64 | subcmd.usage(); | |
65 | } | |
66 | } | |
67 | } | |
68 | None => { | |
69 | println!("Unrecognized command '{}'.", cmd[1]); | |
70 | println!(""); | |
71 | help::usage(); | |
72 | } | |
73 | } | |
74 | } | |
62682a34 | 75 | process::exit(EXIT_STATUS.load(Ordering::SeqCst) as i32); |
1a4d82fc | 76 | } |