blob: 9f453631ff959247bf4cc170a731a21c29090238 (
plain)
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
|
use crate::debian::Debian;
use crate::errors::BumperError;
use crate::rust::Rust;
use std::path::Path;
pub enum ProjectKind {
Rust(Rust),
Debian(Debian),
}
impl ProjectKind {
pub fn detect<P: AsRef<Path>>(dirname: P) -> Result<Vec<ProjectKind>, BumperError> {
let dirname = dirname.as_ref();
let mut kinds = vec![];
if let Ok(p) = Rust::new(dirname) {
kinds.push(ProjectKind::Rust(p));
}
if let Ok(p) = Debian::new(dirname) {
kinds.push(ProjectKind::Debian(p));
}
if kinds.is_empty() {
Err(BumperError::UnknownProjectKind(dirname.to_path_buf()))
} else {
Ok(kinds)
}
}
pub fn set_version(&mut self, version: &str) -> Result<(), BumperError> {
match self {
Self::Rust(ref mut rust) => rust.set_version(version)?,
Self::Debian(ref mut debian) => debian.set_version(version)?,
}
Ok(())
}
}
|