pub struct IgnoreFile { /* private fields */ }Expand description
A single ignore file configuration.
§Example
use cuenv_ignore::IgnoreFile;
let file = IgnoreFile::new("git")
.pattern("node_modules/")
.pattern(".env")
.header("Generated by my-tool");
assert_eq!(file.output_filename(), ".gitignore");Implementations§
Source§impl IgnoreFile
impl IgnoreFile
Sourcepub fn new(tool: impl Into<String>) -> Self
pub fn new(tool: impl Into<String>) -> Self
Create a new ignore file configuration for a tool.
The tool name is used to generate the default filename as .{tool}ignore.
§Example
use cuenv_ignore::IgnoreFile;
let file = IgnoreFile::new("git");
assert_eq!(file.output_filename(), ".gitignore");
let file = IgnoreFile::new("docker");
assert_eq!(file.output_filename(), ".dockerignore");Sourcepub fn pattern(self, pattern: impl Into<String>) -> Self
pub fn pattern(self, pattern: impl Into<String>) -> Self
Add a single pattern to the ignore file.
Sourcepub fn patterns(
self,
patterns: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn patterns( self, patterns: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Add multiple patterns to the ignore file.
Sourcepub fn filename(self, filename: impl Into<String>) -> Self
pub fn filename(self, filename: impl Into<String>) -> Self
Set a custom filename for the ignore file.
If not set, defaults to .{tool}ignore.
Sourcepub fn filename_opt(self, filename: Option<impl Into<String>>) -> Self
pub fn filename_opt(self, filename: Option<impl Into<String>>) -> Self
Optionally set a custom filename for the ignore file.
Sourcepub fn header(self, header: impl Into<String>) -> Self
pub fn header(self, header: impl Into<String>) -> Self
Set a header comment for the ignore file.
The header will be added at the top of the file with # prefixes.
Each line of the header will be prefixed with # .
Sourcepub fn output_filename(&self) -> String
pub fn output_filename(&self) -> String
Get the output filename for this ignore file.
Returns the custom filename if set, otherwise .{tool}ignore.
Sourcepub fn patterns_list(&self) -> &[String]
pub fn patterns_list(&self) -> &[String]
Get the patterns.
Sourcepub fn generate(&self) -> String
pub fn generate(&self) -> String
Generate the file content.
§Example
use cuenv_ignore::IgnoreFile;
let file = IgnoreFile::new("git")
.pattern("node_modules/")
.header("My header");
let content = file.generate();
assert!(content.contains("# My header"));
assert!(content.contains("node_modules/"));Trait Implementations§
Source§impl Clone for IgnoreFile
impl Clone for IgnoreFile
Source§fn clone(&self) -> IgnoreFile
fn clone(&self) -> IgnoreFile
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for IgnoreFile
impl Debug for IgnoreFile
Source§impl PartialEq for IgnoreFile
impl PartialEq for IgnoreFile
impl Eq for IgnoreFile
impl StructuralPartialEq for IgnoreFile
Auto Trait Implementations§
impl Freeze for IgnoreFile
impl RefUnwindSafe for IgnoreFile
impl Send for IgnoreFile
impl Sync for IgnoreFile
impl Unpin for IgnoreFile
impl UnwindSafe for IgnoreFile
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.