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
use std::process::Command;

mod address;
mod certificate;
mod genesis;
mod key;
pub mod rest;
mod transaction;
pub mod votes;

pub use address::AddressCommand;
pub use certificate::CertificateCommand;
pub use genesis::GenesisCommand;
pub use key::KeyCommand;
pub use rest::RestCommand;
pub use transaction::TransactionCommand;
pub use votes::VotesCommand;

pub struct JCliCommand {
    command: Command,
}

impl JCliCommand {
    pub fn new(command: Command) -> Self {
        Self { command }
    }

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

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

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

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

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

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

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