1use structopt::StructOpt;
2
3mod info;
4mod print;
5#[cfg(feature = "http")]
6mod serve;
7
8#[derive(Debug, StructOpt)]
9pub enum Command {
10 Print(print::PrintCommand),
11 Info(info::InfoCommand),
12 #[cfg(feature = "http")]
13 Serve(serve::ServeCommand),
14}
15
16impl Command {
17 #[cfg(feature = "async")]
18 pub async fn execute(self) -> anyhow::Result<()> {
19 match self {
20 Self::Print(command) => command.execute()?,
21 Self::Info(command) => command.execute()?,
22 #[cfg(feature = "http")]
23 Self::Serve(command) => command.execute().await?,
24 }
25
26 Ok(())
27 }
28
29 #[cfg(not(feature = "async"))]
30 pub fn execute(self) -> anyhow::Result<()> {
31 match self {
32 Self::Print(command) => command.execute()?,
33 Self::Info(command) => command.execute()?,
34 }
35
36 Ok(())
37 }
38}