]> git.proxmox.com Git - rustc.git/blob - src/tools/rustbook/help.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / tools / rustbook / help.rs
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
11 //! Implementation of the `help` subcommand. Currently just prints basic usage info.
12
13 use subcommand::Subcommand;
14 use error::CliResult;
15 use error::CommandResult;
16 use term::Term;
17
18 struct Help;
19
20 pub fn parse_cmd(name: &str) -> Option<Box<Subcommand>> {
21 match name {
22 "help" | "--help" | "-h" | "-?" => Some(Box::new(Help)),
23 _ => None
24 }
25 }
26
27 impl Subcommand for Help {
28 fn parse_args(&mut self, _: &[String]) -> CliResult<()> {
29 Ok(())
30 }
31 fn usage(&self) {}
32 fn execute(&mut self, _: &mut Term) -> CommandResult<()> {
33 usage();
34 Ok(())
35 }
36 }
37
38 pub fn usage() {
39 println!("Usage: rustbook <command> [<args>]");
40 println!("");
41 println!("The <command> must be one of:");
42 println!(" help Print this message.");
43 println!(" build Build the book in subdirectory _book");
44 println!(" serve --NOT YET IMPLEMENTED--");
45 println!(" test --NOT YET IMPLEMENTED--");
46 }