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
mod from_bytes;
mod generate;
mod to_bytes;
mod to_public;

pub use from_bytes::KeyFromBytesCommand;
pub use generate::KeyGenerateCommand;
use std::process::Command;
pub use to_bytes::KeyToBytesCommand;
pub use to_public::KeyToPublicCommand;

pub struct KeyCommand {
    command: Command,
}

#[allow(clippy::wrong_self_convention)]
impl KeyCommand {
    pub fn new(command: Command) -> Self {
        Self { command }
    }

    pub fn generate(mut self) -> KeyGenerateCommand {
        self.command.arg("generate");
        KeyGenerateCommand::new(self.command)
    }

    pub fn to_bytes(mut self) -> KeyToBytesCommand {
        self.command.arg("to-bytes");
        KeyToBytesCommand::new(self.command)
    }

    pub fn from_bytes(mut self) -> KeyFromBytesCommand {
        self.command.arg("from-bytes");
        KeyFromBytesCommand::new(self.command)
    }

    pub fn to_public(mut self) -> KeyToPublicCommand {
        self.command.arg("to-public");
        KeyToPublicCommand::new(self.command)
    }
}