mago_service/source/
config.rs

1use std::path::PathBuf;
2
3use serde::Deserialize;
4use serde::Serialize;
5
6/// Configuration options for source discovery.
7#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8pub struct SourceConfiguration {
9    /// The root directory from which to start scanning.
10    ///
11    /// Defaults to the current working directory.
12    pub root: PathBuf,
13
14    /// Paths to user defined source files.
15    ///
16    /// If empty, all files in the root directory are included.
17    ///
18    /// Defaults to `[]`.
19    pub paths: Vec<PathBuf>,
20
21    /// Paths to non-user defined files to include in the scan.
22    ///
23    /// Defaults to `[]`.
24    pub includes: Vec<PathBuf>,
25
26    /// Patterns to exclude from the scan.
27    ///
28    /// Defaults to `[]`.
29    pub excludes: Vec<String>,
30
31    /// File extensions to filter by.
32    ///
33    /// Defaults to `[".php"]`.
34    pub extensions: Vec<String>,
35}
36
37impl SourceConfiguration {
38    /// Creates a new `SourceConfiguration` with the given root directory.
39    ///
40    /// # Arguments
41    ///
42    /// * `root` - The root directory from which to start scanning.
43    ///
44    /// # Returns
45    ///
46    /// A new `SourceConfiguration` with the given root directory.
47    pub fn from_root(root: PathBuf) -> Self {
48        Self { root, paths: vec![], includes: vec![], excludes: vec![], extensions: vec![] }
49    }
50}