1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright © 2015 - Samuel Dolt <samuel@dolt.ch>
//
// Licensed under the MIT license. This file may not be copied, modified,
// or distributed except according to those terms.
//
// See the COPYRIGHT file at the top-level directory of this distribution.
//! Cargo style subcommand
//!
//! This library help to build an app that use a similar command line interface
//! as Cargo or Git.
//!
//! # Example
//!
//! The following example show a simple program with two subcommand:
//!
//! - `cargo build`
//! - `cargo clean`
//!
//! ```
//! extern crate subcmd;
//! use subcmd::CmdHandler;
//! use subcmd::Command;
//!
//! struct CmdBuild;
//!
//! impl Command for CmdBuild {
//! fn name<'a>(&self) -> &'a str {"build"}
//! fn help<'a>(&self) -> &'a str {"Usage: cargo build [options]"}
//! fn description<'a>(&self) -> &'a str { "Compile the current project" }
//! fn run(&self, argv: &Vec<String>) {
//! println!("I'm building your files");
//! }
//! }
//!
//! struct CmdClean;
//!
//! impl Command for CmdClean {
//! fn name<'a>(&self) -> &'a str {"clean"}
//! fn help<'a>(&self) -> &'a str {"Usage: cargo clean [options]"}
//! fn description<'a>(&self) -> &'a str { "Remove the target directory" }
//! fn run(&self, argv: &Vec<String>) {
//! println!("I'm cleaning your files");
//! }
//! }
//!
//! fn main() {
//! let mut handler = CmdHandler::new();
//! handler.add(Box::new(CmdBuild));
//! handler.add(Box::new(CmdClean));
//! handler.run();
//! }
//! ```
extern crate getopts;
extern crate tabwriter;
extern crate strsim;
extern crate ansi_term;
pub use CmdHandler;
pub use Message;
pub use CmdResult;
pub use CmdWrapper;
/// This trait must be implemented for each subcommand