Struct tokei::Config

source ·
pub struct Config {
    pub columns: Option<usize>,
    pub hidden: Option<bool>,
    pub no_ignore: Option<bool>,
    pub no_ignore_parent: Option<bool>,
    pub no_ignore_dot: Option<bool>,
    pub no_ignore_vcs: Option<bool>,
    pub treat_doc_strings_as_comments: Option<bool>,
    pub sort: Option<Sort>,
    pub types: Option<Vec<LanguageType>>,
    pub for_each_fn: Option<fn(_: LanguageType, _: Report)>,
}
Expand description

A configuration struct for how Languages::get_statistics searches and counts languages.

use tokei::Config;

let config = Config {
    treat_doc_strings_as_comments: Some(true),
    ..Config::default()
};

Fields§

§columns: Option<usize>

Width of columns to be printed to the terminal. This option is ignored in the library. Default: Auto detected width of the terminal.

§hidden: Option<bool>

Count hidden files and directories. Default: false.

§no_ignore: Option<bool>

Don’t respect ignore files (.gitignore, .ignore, etc.). This implies –no-ignore-parent, –no-ignore-dot, and –no-ignore-vcs. Default: false.

§no_ignore_parent: Option<bool>

Don’t respect ignore files (.gitignore, .ignore, etc.) in parent directories. Default: false.

§no_ignore_dot: Option<bool>

Don’t respect .ignore and .tokeignore files, including those in parent directories. Default: false.

§no_ignore_vcs: Option<bool>

Don’t respect VCS ignore files (.gitignore, .hgignore, etc.), including those in parent directories. Default: false.

§treat_doc_strings_as_comments: Option<bool>

Whether to treat doc strings in languages as comments. Default: false.

§sort: Option<Sort>

Sort languages. Default: None.

§types: Option<Vec<LanguageType>>

Filters languages searched to just those provided. E.g. A directory containing C, Cpp, and Rust with a Config.types of [Cpp, Rust] will count only Cpp and Rust. Default: None.

§for_each_fn: Option<fn(_: LanguageType, _: Report)>

Whether to output only the paths for downstream batch processing Default: false adds a closure for each function, e.g., print the result

Implementations§

source§

impl Config

source

pub fn from_config_files() -> Self

Creates a Config from three configuration files if they are available. Files can have two different names tokei.toml and .tokeirc. Firstly it will attempt to find a config in the configuration directory (see below), secondly from the home directory, $HOME/, and thirdly from the current directory, ./. The current directory’s configuration will take priority over the configuration directory.

PlatformValueExample
Linux$XDG_CONFIG_HOME or $HOME/.config/home/alice/.config
macOS$HOME/Library/Application Support/Users/Alice/Library/Application Support
Windows{FOLDERID_RoamingAppData}C:\Users\Alice\AppData\Roaming
Example
columns = 80
types = ["Python"]
treat_doc_strings_as_comments = true

Trait Implementations§

source§

impl Debug for Config

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Config

source§

fn default() -> Config

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

impl<'de> Deserialize<'de> for Config

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 = mem::align_of::<T>()

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,