pub struct IgnoreFilesBuilder { /* private fields */ }Expand description
Builder for generating multiple ignore files.
§Example
use cuenv_ignore::{IgnoreFile, IgnoreFiles};
let result = IgnoreFiles::builder()
.directory("/path/to/project")
.require_git_repo(true)
.dry_run(false)
.file(IgnoreFile::new("git")
.pattern("node_modules/")
.pattern(".env"))
.file(IgnoreFile::new("docker")
.pattern("target/"))
.generate()?;Implementations§
Source§impl IgnoreFilesBuilder
impl IgnoreFilesBuilder
Sourcepub fn directory(self, dir: impl AsRef<Path>) -> Self
pub fn directory(self, dir: impl AsRef<Path>) -> Self
Set the directory where ignore files will be generated.
Defaults to the current directory if not set.
Sourcepub fn file(self, file: IgnoreFile) -> Self
pub fn file(self, file: IgnoreFile) -> Self
Add a single ignore file configuration.
Sourcepub fn files(self, files: impl IntoIterator<Item = IgnoreFile>) -> Self
pub fn files(self, files: impl IntoIterator<Item = IgnoreFile>) -> Self
Add multiple ignore file configurations.
Sourcepub const fn require_git_repo(self, require: bool) -> Self
pub const fn require_git_repo(self, require: bool) -> Self
Require that the directory is within a Git repository.
Defaults to false. When true, returns an error if the directory
is not within a Git repository.
Sourcepub const fn dry_run(self, dry_run: bool) -> Self
pub const fn dry_run(self, dry_run: bool) -> Self
Enable dry-run mode.
When true, no files will be written. The result will indicate
what would happen with WouldCreate and WouldUpdate statuses.
Sourcepub fn generate(self) -> Result<SyncResult>
pub fn generate(self) -> Result<SyncResult>
Generate the ignore files.
§Errors
Returns an error if:
require_git_repois true and the directory is not within a Git repository- A tool name contains invalid characters (path separators)
- File I/O fails
Trait Implementations§
Source§impl Debug for IgnoreFilesBuilder
impl Debug for IgnoreFilesBuilder
Source§impl Default for IgnoreFilesBuilder
impl Default for IgnoreFilesBuilder
Source§fn default() -> IgnoreFilesBuilder
fn default() -> IgnoreFilesBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for IgnoreFilesBuilder
impl RefUnwindSafe for IgnoreFilesBuilder
impl Send for IgnoreFilesBuilder
impl Sync for IgnoreFilesBuilder
impl Unpin for IgnoreFilesBuilder
impl UnsafeUnpin for IgnoreFilesBuilder
impl UnwindSafe for IgnoreFilesBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more