Skip to main content

bylaw_analyzer/
options.rs

1use bylaw_core::TargetKind;
2use camino::Utf8PathBuf;
3use indexmap::IndexSet;
4
5#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
6pub enum IncompleteAnalysisPolicy {
7    #[default]
8    Deny,
9    Allow,
10}
11
12#[derive(Clone, Debug, Eq, PartialEq)]
13pub struct AnalysisOptions {
14    pub manifest_path: Utf8PathBuf,
15    pub selected_package_names: Vec<String>,
16    pub features: Vec<String>,
17    pub all_features: bool,
18    pub no_default_features: bool,
19    pub target_triple: Option<String>,
20    pub included_target_kinds: IndexSet<TargetKind>,
21    pub enable_proc_macros: bool,
22    pub enable_build_scripts: bool,
23    pub incomplete_policy: IncompleteAnalysisPolicy,
24}
25
26impl AnalysisOptions {
27    pub fn new(manifest_path: impl Into<Utf8PathBuf>) -> Self {
28        Self {
29            manifest_path: manifest_path.into(),
30            ..Self::default()
31        }
32    }
33}
34
35impl Default for AnalysisOptions {
36    fn default() -> Self {
37        Self {
38            manifest_path: Utf8PathBuf::from("Cargo.toml"),
39            selected_package_names: Vec::new(),
40            features: Vec::new(),
41            all_features: false,
42            no_default_features: false,
43            target_triple: None,
44            included_target_kinds: IndexSet::from([TargetKind::Library, TargetKind::Binary]),
45            enable_proc_macros: true,
46            enable_build_scripts: true,
47            incomplete_policy: IncompleteAnalysisPolicy::Deny,
48        }
49    }
50}