dirgrab_lib/
config.rs

1// --- FILE: dirgrab-lib/src/config.rs ---
2
3use std::path::PathBuf; // Needed for the struct definition
4
5/// Configuration for the dirgrab operation.
6///
7/// This struct holds all the settings needed to control how `dirgrab`
8/// finds and processes files within the specified target directory.
9/// It is typically constructed by the calling application (e.g., the CLI)
10/// based on user input.
11#[derive(Debug, Clone)]
12pub struct GrabConfig {
13    // Made public here
14    /// The starting path for the operation (directory or Git repository).
15    /// `dirgrab` will operate within this path. It will be canonicalized internally.
16    pub target_path: PathBuf,
17
18    /// If true, adds `'--- FILE: <filename> ---'` headers before each file's content
19    /// in the final output string. The filename displayed will be relative to the
20    /// Git repository root (if applicable) or the target path.
21    pub add_headers: bool,
22
23    /// A list of glob patterns (using .gitignore syntax) to exclude files or directories.
24    /// These patterns are applied *in addition* to any `.gitignore` rules if operating
25    /// in Git mode.
26    /// In Git mode, they are passed to `git ls-files` as `:!<pattern>` pathspecs.
27    /// In non-Git mode, they are used to filter the results from walking the directory.
28    pub exclude_patterns: Vec<String>,
29
30    /// If operating in Git mode, set this to true to include untracked files
31    /// (files present in the working directory but not added to the index).
32    /// This still respects `.gitignore` and the `exclude_patterns`.
33    /// This setting has no effect if the `target_path` is not part of a Git repository,
34    /// or if `no_git` is true.
35    pub include_untracked: bool,
36
37    /// If true, the default exclusion for `dirgrab.txt` will *not* be applied.
38    /// Use this flag only if you specifically need to include a file named `dirgrab.txt`.
39    pub include_default_output: bool,
40
41    /// If true, forces dirgrab to ignore any Git repository context and treat the
42    /// target path purely as a filesystem directory. This disables `.gitignore`
43    /// processing and the effect of `include_untracked`. User-provided exclude
44    /// patterns (`-e`) are still respected.
45    pub no_git: bool,
46
47    /// If true, prepend an indented directory tree structure to the output,
48    /// showing the files and directories included in the grab operation.
49    pub include_tree: bool,
50
51    /// If true, attempt to extract text content from PDF files.
52    pub convert_pdf: bool, // <-- Field added here
53
54    /// If true, operate on the entire Git repository even when the target path is a subdirectory.
55    pub all_repo: bool,
56}