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
use crate::resp::{CommandArgs, IntoArgs};
#[must_use]
#[inline(always)]
pub fn cmd(name: &'static str) -> Command {
Command::new(name)
}
#[derive(Debug)]
pub struct Command {
pub name: &'static str,
pub args: CommandArgs,
}
impl Command {
#[must_use]
#[inline(always)]
pub fn new(name: &'static str) -> Self {
Self {
name,
args: CommandArgs::default(),
}
}
#[must_use]
#[inline(always)]
pub fn arg<A>(self, arg: A) -> Self
where
A: IntoArgs,
{
Self {
name: self.name,
args: self.args.arg(arg),
}
}
#[must_use]
#[inline(always)]
pub fn arg_if<A>(self, condition: bool, arg: A) -> Self
where
A: IntoArgs,
{
Self {
name: self.name,
args: self.args.arg_if(condition, arg),
}
}
}