pub struct ConfigBuilder { /* private fields */ }Expand description
ConfigBuilder - The Architect Behind Your CountRoo Configuration 🏗️📐
Craft the perfect configuration for your CountRoo analysis with this builder.
Whether you’re setting up a simple count or gearing up for a deep dive into your project’s
structure, ConfigBuilder paves the way for a customized analysis experience. Think of it
as laying out the blueprint for CountRoo’s adventure through your codebase. 🗺️✨
§Features
- Project Path: Direct
CountRooto the heart of your project. Whether it’s the root or a specific folder, just set the path, and off you go! 🚀 - Extensions: Specify which file extensions should catch
CountRoo’s eye. Rust files? Markdown? Configuration files? You decide! 📂👀 - Count Empty Lines: To count or not to count empty lines, that is the question.
With
ConfigBuilder, the choice is yours. 📄🚫📄
§Usage
Building your Config is as easy as chaining method calls with ConfigBuilder. Here’s a
quick example to get you started:
use countroo::prelude::*;
let config = ConfigBuilder::default()
.project_path("src")
.extension("rs")
.count_empty_lines(true)
.build()
.expect("Failed to build the config. Please check your settings!");With ConfigBuilder, you’re the master planner behind CountRoo’s analytical journey.
Set your preferences, build your config, and let the code counting commence! 🎉🔧
Implementations§
Source§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn project_path(self, path: &str) -> Self
pub fn project_path(self, path: &str) -> Self
Sets the project path for CountRoo’s code exploration journey. 🚀🗂️
This method defines the starting point of your project, guiding CountRoo on where
to begin its analysis. Whether it’s nestled in your project’s root or tucked away in
a subdirectory, point CountRoo in the right direction, and it’ll happily hop to it.
§Parameters
path: A string slice (&str) indicating the path to your project’s source directory. It can be an absolute path or a relative path from the location ofCargo.toml.
§Behavior
- Relative Paths: If you pass a relative path,
CountRoosmartly resolves it based on the location of yourCargo.tomlfile. It’s like givingCountRooa little map. 🗺️ - Absolute Paths: Direct
CountRoowith confidence if you’ve got an absolute path. It’ll head straight there, no questions asked. 🏃♂️💨
§Returns
Keeps the builder pattern grooving by returning self, allowing for more method chaining.
§Example Usage
use countroo::prelude::*;
let config = ConfigBuilder::default()
.project_path("src") // Directing to the src directory
.extension("rs") // We're only interested in Rust files
.count_empty_lines(true) // Counting every line, even the empty ones
.build()
.expect("Building config failed. Oh no!");By setting the project path, you ensure CountRoo starts its adventure from the
correct location, making your code analysis as accurate and helpful as possible. 🌟
Sourcepub fn extension(self, ext: &str) -> Self
pub fn extension(self, ext: &str) -> Self
Adds a single file extension to the list for code analysis consideration. 📄🔍
Tailor CountRoo’s adventurous path by specifying individual file types it should
pay attention to. Perfect for when you want to focus on just one more extension
without disturbing the existing list. Like inviting just one more friend to your
coding party! 🎉
§Parameters
ext: A string slice (&str) representing a single file extension to include in the analysis. Remember, no leading dot (.) needed!
§Returns
Returns self, keeping the builder pattern fluent and fabulous. 🔄
§Example Usage
use countroo::prelude::*;
let config = ConfigBuilder::default()
.project_path("/path/to/glorious/project")
.extension("rs") // Just focusing on Rust files here!
.count_empty_lines(true) // Every line counts, even the empty ones!
.build()
.unwrap_or_else(|_| panic!("Failed to build the Config. This is not a drill!"));By specifying the types of files to analyze, you make CountRoo’s job both
easier and more aligned with your project’s needs. Let the targeted analysis begin! 🎯🚀
Sourcepub fn extensions(self, exts: Vec<&str>) -> Self
pub fn extensions(self, exts: Vec<&str>) -> Self
Adds a list of file extensions to be included in the code analysis. 📁✨
This method allows you to specify which file types CountRoo should consider
when it embarks on its code counting journey. Whether you’re looking at Rust files,
Markdown documents, or even configuration files, just list their extensions here.
§Parameters
exts: A vector of string slices (&str) representing the file extensions to include in the analysis, without the leading dot (.).
§Returns
Returns self, enabling the delightful chaining of builder method calls. 🔄
§Example Usage
use countroo::prelude::*;
let config = ConfigBuilder::default()
.project_path("/path/to/project")
.extensions(vec!["rs", "md", "toml"]) // Rustacean essentials!
.count_empty_lines(false) // Skipping those empty lines.
.build()
.expect("Oops! Failed to construct the Config");Expand your analysis horizon by including a variety of file types,
making CountRoo your versatile code exploration companion. 🌐🔍
Sourcepub fn count_empty_lines(self, count: bool) -> Self
pub fn count_empty_lines(self, count: bool) -> Self
Sets the flag to count (or not count) empty lines in the code analysis. 📝✔️❌
This method configures whether CountRoo should consider empty lines as part of
its line counting expedition across your project. It’s like choosing whether to
count the spaces between the trees in a forest. 🌳🌲
§Parameters
count: A boolean value wheretruesignalsCountRooto count every single line, including those sneaky empty ones, andfalsemeans skipping over those airy voids.
§Returns
Returns self, allowing for fluent-style chaining of builder methods. 🔄
§Example Usage
use countroo::prelude::*;
let config = ConfigBuilder::default()
.project_path("/path/to/project")
.extension("rs")
.count_empty_lines(true) // We care about every line, even the empty ones!
.build()
.expect("Config build failed");Whether your coding style is verbose, with plenty of breathing room, or compact,
with not an empty line in sight, CountRoo adapts to your preferences. 🎨
Sourcepub fn build(self) -> Result<Config, &'static str>
pub fn build(self) -> Result<Config, &'static str>
Builds the Config object from the builder pattern setup. 🏗️🛠️
Consumes the builder to produce a finalized Config instance, encapsulating all
the project-specific settings necessary for the CountRoo analysis. This function
checks that all required fields are set, ensuring the builder is in a valid state
before attempting to construct a Config object.
§Returns
Ok(Config): A shiny newConfigobject ready to guideCountRooon its journey 🧭.Err(&'static str): A not-so-shiny error message indicating what went wrong during the build process. 😓
§Example Usage
use countroo::prelude::*;
let builder = ConfigBuilder::default()
.project_path("path/to/my/rust/project")
.extension("rs")
.count_empty_lines(true);
let config = builder.build().expect("Failed to build config");Ensure your project path is set; otherwise, this build will politely refuse to proceed, citing a lack of directions. 🚫🗺️
Trait Implementations§
Source§impl Default for ConfigBuilder
impl Default for ConfigBuilder
Source§fn default() -> ConfigBuilder
fn default() -> ConfigBuilder
Auto Trait Implementations§
impl Freeze for ConfigBuilder
impl RefUnwindSafe for ConfigBuilder
impl Send for ConfigBuilder
impl Sync for ConfigBuilder
impl Unpin for ConfigBuilder
impl UnwindSafe for ConfigBuilder
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more