pub struct Runner { /* private fields */ }
Implementations§
Source§impl Runner
impl Runner
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new instance of the runner and sets all default values
Examples found in repository?
More examples
examples/project_meta_data.rs (line 12)
5fn main() {
6
7 let meta_data = ApplicationMetaData::new(
8 "Test CLI".to_string(),
9 "A test application".to_string()
10 );
11
12 let mut runner = Runner::new();
13 runner.set_meta_data(meta_data);
14 runner.enable_command_handler(CommandHandlerArguments {
15 commands: vec![],
16 default_no_argument_callback: None,
17 flags: vec![]
18 });
19 runner.run();
20}
examples/pong_default.rs (line 26)
15fn main() {
16
17 // defines the base command
18 let pong_command = Command::new(
19 "Pong".to_string(),
20 "Pong command".to_string(),
21 "usage".to_string(),
22 executor,
23 "ping".to_string()
24 );
25
26 let mut runner = Runner::new();
27 runner.enable_command_handler(CommandHandlerArguments {
28 commands: vec![pong_command],
29 default_no_argument_callback: None,
30 flags: vec![]
31 });
32 runner.run();
33}
examples/flag_values.rs (line 29)
12fn main() {
13
14 let command = Command::new(
15 "Test".to_string(),
16 "test command".to_string(),
17 "normal usage".to_string(),
18 executor,
19 "test".to_string()
20 );
21
22 let flag = Flag::new(
23 "testFlag".to_string(),
24 vec!["tf".to_string()],
25 true
26 );
27
28
29 let mut runner = Runner::new();
30 runner.enable_command_handler(CommandHandlerArguments {
31 commands: vec![command],
32 default_no_argument_callback: None,
33 flags: vec![flag]
34 });
35 runner.run();
36}
examples/flags.rs (line 29)
12fn main() {
13
14 let command = Command::new(
15 "Test".to_string(),
16 "test command".to_string(),
17 "normal usage".to_string(),
18 executor,
19 "test".to_string()
20 );
21
22 let flag = Flag::new(
23 "testFlag".to_string(),
24 vec!["tf".to_string()],
25 false
26 );
27
28
29 let mut runner = Runner::new();
30 runner.enable_command_handler(CommandHandlerArguments {
31 commands: vec![command],
32 default_no_argument_callback: None,
33 flags: vec![flag]
34 });
35 runner.run();
36}
Sourcepub fn enable_command_handler(&mut self, config: CommandHandlerArguments)
pub fn enable_command_handler(&mut self, config: CommandHandlerArguments)
Enables the internal command handler And sets the provided arguments of the command handler
NOTE: This method that should be executed as final step, because it depends on steps before.
Examples found in repository?
More examples
examples/project_meta_data.rs (lines 14-18)
5fn main() {
6
7 let meta_data = ApplicationMetaData::new(
8 "Test CLI".to_string(),
9 "A test application".to_string()
10 );
11
12 let mut runner = Runner::new();
13 runner.set_meta_data(meta_data);
14 runner.enable_command_handler(CommandHandlerArguments {
15 commands: vec![],
16 default_no_argument_callback: None,
17 flags: vec![]
18 });
19 runner.run();
20}
examples/pong_default.rs (lines 27-31)
15fn main() {
16
17 // defines the base command
18 let pong_command = Command::new(
19 "Pong".to_string(),
20 "Pong command".to_string(),
21 "usage".to_string(),
22 executor,
23 "ping".to_string()
24 );
25
26 let mut runner = Runner::new();
27 runner.enable_command_handler(CommandHandlerArguments {
28 commands: vec![pong_command],
29 default_no_argument_callback: None,
30 flags: vec![]
31 });
32 runner.run();
33}
examples/flag_values.rs (lines 30-34)
12fn main() {
13
14 let command = Command::new(
15 "Test".to_string(),
16 "test command".to_string(),
17 "normal usage".to_string(),
18 executor,
19 "test".to_string()
20 );
21
22 let flag = Flag::new(
23 "testFlag".to_string(),
24 vec!["tf".to_string()],
25 true
26 );
27
28
29 let mut runner = Runner::new();
30 runner.enable_command_handler(CommandHandlerArguments {
31 commands: vec![command],
32 default_no_argument_callback: None,
33 flags: vec![flag]
34 });
35 runner.run();
36}
examples/flags.rs (lines 30-34)
12fn main() {
13
14 let command = Command::new(
15 "Test".to_string(),
16 "test command".to_string(),
17 "normal usage".to_string(),
18 executor,
19 "test".to_string()
20 );
21
22 let flag = Flag::new(
23 "testFlag".to_string(),
24 vec!["tf".to_string()],
25 false
26 );
27
28
29 let mut runner = Runner::new();
30 runner.enable_command_handler(CommandHandlerArguments {
31 commands: vec![command],
32 default_no_argument_callback: None,
33 flags: vec![flag]
34 });
35 runner.run();
36}
Sourcepub fn enable_custom_executor(&mut self, executor: fn(arguments: Args))
pub fn enable_custom_executor(&mut self, executor: fn(arguments: Args))
Sets the custom executor that can contain any argument based operation with the system.
Sourcepub fn set_meta_data(&mut self, data: ApplicationMetaData)
pub fn set_meta_data(&mut self, data: ApplicationMetaData)
Sets the meta data of the application
Examples found in repository?
examples/project_meta_data.rs (line 13)
5fn main() {
6
7 let meta_data = ApplicationMetaData::new(
8 "Test CLI".to_string(),
9 "A test application".to_string()
10 );
11
12 let mut runner = Runner::new();
13 runner.set_meta_data(meta_data);
14 runner.enable_command_handler(CommandHandlerArguments {
15 commands: vec![],
16 default_no_argument_callback: None,
17 flags: vec![]
18 });
19 runner.run();
20}
Sourcepub fn run(&mut self)
pub fn run(&mut self)
Executes the main runner. If there is a command handler provided, the command handler will be used for executing the commands. Otherwise a custom handler has been provided that is executed
Examples found in repository?
More examples
examples/project_meta_data.rs (line 19)
5fn main() {
6
7 let meta_data = ApplicationMetaData::new(
8 "Test CLI".to_string(),
9 "A test application".to_string()
10 );
11
12 let mut runner = Runner::new();
13 runner.set_meta_data(meta_data);
14 runner.enable_command_handler(CommandHandlerArguments {
15 commands: vec![],
16 default_no_argument_callback: None,
17 flags: vec![]
18 });
19 runner.run();
20}
examples/pong_default.rs (line 32)
15fn main() {
16
17 // defines the base command
18 let pong_command = Command::new(
19 "Pong".to_string(),
20 "Pong command".to_string(),
21 "usage".to_string(),
22 executor,
23 "ping".to_string()
24 );
25
26 let mut runner = Runner::new();
27 runner.enable_command_handler(CommandHandlerArguments {
28 commands: vec![pong_command],
29 default_no_argument_callback: None,
30 flags: vec![]
31 });
32 runner.run();
33}
examples/flag_values.rs (line 35)
12fn main() {
13
14 let command = Command::new(
15 "Test".to_string(),
16 "test command".to_string(),
17 "normal usage".to_string(),
18 executor,
19 "test".to_string()
20 );
21
22 let flag = Flag::new(
23 "testFlag".to_string(),
24 vec!["tf".to_string()],
25 true
26 );
27
28
29 let mut runner = Runner::new();
30 runner.enable_command_handler(CommandHandlerArguments {
31 commands: vec![command],
32 default_no_argument_callback: None,
33 flags: vec![flag]
34 });
35 runner.run();
36}
examples/flags.rs (line 35)
12fn main() {
13
14 let command = Command::new(
15 "Test".to_string(),
16 "test command".to_string(),
17 "normal usage".to_string(),
18 executor,
19 "test".to_string()
20 );
21
22 let flag = Flag::new(
23 "testFlag".to_string(),
24 vec!["tf".to_string()],
25 false
26 );
27
28
29 let mut runner = Runner::new();
30 runner.enable_command_handler(CommandHandlerArguments {
31 commands: vec![command],
32 default_no_argument_callback: None,
33 flags: vec![flag]
34 });
35 runner.run();
36}
Auto Trait Implementations§
impl Freeze for Runner
impl RefUnwindSafe for Runner
impl Send for Runner
impl Sync for Runner
impl Unpin for Runner
impl UnwindSafe for Runner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more