rusty_cli/commands/
command.rs

1use crate::flags::flag::Flags;
2
3pub type Callback = fn(flags: Flags);
4
5/// Defines the base information of a command
6/// that needs to be delivered
7#[derive(Clone)]
8pub struct Command {
9    /// The title of the command
10    pub title: String,
11    /// The description of the command
12    pub description: String,
13    /// The usage of the command
14    pub usage: String,
15    /// The function that is executed if the command should be executed
16    pub executor: Callback,
17    /// The argument that indicates if the command should be executed
18    pub caller_arg: String
19}
20
21impl Command {
22
23    /// Creates a new command
24    /// from the provided values
25    pub fn new(title: String, description: String, usage: String, executor: Callback, caller_arg: String) -> Self
26    {
27        Command {title, description, usage, executor, caller_arg}
28    }
29}