Struct countroo::ConfigBuilder

source ·
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 CountRoo to 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

source

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 of Cargo.toml.
§Behavior
  • Relative Paths: If you pass a relative path, CountRoo smartly resolves it based on the location of your Cargo.toml file. It’s like giving CountRoo a little map. 🗺️
  • Absolute Paths: Direct CountRoo with 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. 🌟

source

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! 🎯🚀

source

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. 🌐🔍

source

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 where true signals CountRoo to count every single line, including those sneaky empty ones, and false means 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. 🎨

source

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 new Config object ready to guide CountRoo on 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

source§

fn default() -> ConfigBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more