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
use crate::prelude::*;
use serde::{Deserialize, Serialize};
use std::{
env,
path::{Path, PathBuf},
process::exit,
};
pub fn target_app_root(manifest_path: Option<&Path>) -> PathBuf {
match manifest_path {
Some(path) => {
if !path.exists() || path.parent().is_none() {
status_err!("the manifest-path must be a path to a Cargo.toml file");
exit(1);
}
path.parent().unwrap().to_owned()
}
None => {
let cwd = env::current_dir()
.expect("couldn't get current working directory!")
.canonicalize()
.expect("couldn't canonicalize current working directory!");
let mut path = cwd.as_path();
loop {
if path.join("Cargo.toml").exists() {
return path.to_owned();
}
match path.parent() {
Some(p) => path = p,
None => {
status_err!("couldn't find application root!");
exit(1);
}
}
}
}
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct CliConfig {
}