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
pub mod build;
pub mod init;
pub mod version;
use self::{build::BuildCmd, init::InitCmd, version::VersionCmd};
use crate::config::{CargoConfig, CARGO_CONFIG_FILE};
use abscissa_core::{Command, Configurable, FrameworkError, Help, Options, Runnable};
use std::path::PathBuf;
#[derive(Command, Debug, Options, Runnable)]
pub enum CargoRpmCmd {
#[options(help = "build RPMs from Rust projects using Cargo")]
Rpm(RpmCommand),
}
#[derive(Command, Debug, Options, Runnable)]
pub enum RpmCommand {
#[options(help = "get usage information")]
Help(Help<Self>),
#[options(help = "build an RPM out of the current project")]
Build(BuildCmd),
#[options(help = "initialize a Rust project with RPM support")]
Init(InitCmd),
#[options(help = "display version information")]
Version(VersionCmd),
}
impl Configurable<CargoConfig> for CargoRpmCmd {
fn config_path(&self) -> Option<PathBuf> {
let filename = PathBuf::from(CARGO_CONFIG_FILE);
if filename.exists() {
Some(filename)
} else {
None
}
}
fn process_config(&self, config: CargoConfig) -> Result<CargoConfig, FrameworkError> {
match self {
CargoRpmCmd::Rpm(_cmd) => Ok(config),
}
}
}