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
90
91
92
93
//! **Cmdr is a library for building line-oriented text-based user interfaces.**
//! It lets you focus on writing the implementations of your commands while it handles user
//! interaction, parsing etc.
//!
//! Out of the box CMDR gives you;
//! - Command line parsing
//! - Command history
//! - Help functions and discoverability
//! - Auto completion (not yet implemented)
//!
//! To use CMDR you write the commands you want your user to interact with as functions on one or
//! more Scope types. By implementing the scope trait cmdr can implement and execute your supplied
//! commands.
//! Implementing the Scope trait is as easy by using the supplied cmdr macro and annotating your
//! commands with the cmd annotation to provide useful metadata on your commands. Doc strings in
//! your command will be picked up automatically and used as help text.
//!
//! ```ignore
//! use cmdr::*;
//!
//! /// Example scope that implements two commands, greet and quit
//! struct GreeterScope {}
//!
//! #[cmdr]
//! use cmdr::*;
//!
//! /// Example scope that implements two commands, greet and quit
//! struct GreeterScope {}
//!
//! #[cmdr]
//! impl GreeterScope {
//! /// Cmdr command to greet someone. Takes one parameter and prints a greeting
//! #[cmd]
//! fn greet(&self, args: &[String]) -> CommandResult {
//! println!("Hello {}", args[0]);
//! Ok(Action::Done)
//! }
//!
//! /// Cmdr command to quit the application by returning CommandResult::Quit
//! #[cmd]
//! fn quit(&self, _args: &[String]) -> CommandResult {
//! println!("Quitting");
//! Ok(Action::Quit)
//! }
//! }
//!
//! /// Main function that creates the scope and starts a command loop for it
//! fn main() -> cmdr::Result<()> {
//! cmd_loop(&mut GreeterScope {})?;
//! Ok(())
//! }
//! ```
//! ## More information
//! - [API documentation](https://docs.rs/cmdr/)
//! - [Github repository](https://github.com/mendelt/cmdr)
//! - [Crates.io](https://crates.io/crates/cmdr)
//! - [Release notes](https://github.com/mendelt/cmdr/releases)
// Turn on warnings for some lints
pub use crate;
pub use crate Line;
use crate RustyLineReader;
pub use crate LineWriter;
pub use crate;
pub use crate Runner;
pub use crate Scope;
pub use ;
use PrintlnWriter;
/// This is the main entry-point to the cmdr library.
/// Creates a LineReader and executes its command on the scope that is passed to it.