pub struct FormatterConfig {
pub indent_width: usize,
pub use_tabs: bool,
pub quote_variables: bool,
pub use_double_brackets: bool,
pub normalize_functions: bool,
pub inline_then: bool,
pub space_before_brace: bool,
pub preserve_blank_lines: bool,
pub max_blank_lines: usize,
pub ignore_patterns: Vec<String>,
}Expand description
Configuration for bash script formatting
§Examples
use bashrs::bash_quality::FormatterConfig;
let config = FormatterConfig::default();
assert_eq!(config.indent_width, 2);
assert!(!config.use_tabs);Fields§
§indent_width: usizeNumber of spaces per indentation level (default: 2, bash standard)
use_tabs: boolUse tabs instead of spaces for indentation (default: false)
quote_variables: boolQuote all variable expansions (default: true)
use_double_brackets: boolUse [[ ]] instead of [ ] for tests (default: true)
normalize_functions: boolNormalize function syntax to name() { } (default: true)
inline_then: boolPut ‘then’ on same line as ‘if’ (default: true)
space_before_brace: boolAdd space before function braces (default: true)
preserve_blank_lines: boolPreserve existing blank lines (default: true)
max_blank_lines: usizeMaximum consecutive blank lines (default: 2)
ignore_patterns: Vec<String>Ignore files matching these patterns (default: empty)
Implementations§
Source§impl FormatterConfig
impl FormatterConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new configuration with default values
§Examples
use bashrs::bash_quality::FormatterConfig;
let config = FormatterConfig::new();
assert_eq!(config.indent_width, 2);Sourcepub fn from_toml(toml_str: &str) -> Result<Self, String>
pub fn from_toml(toml_str: &str) -> Result<Self, String>
Load configuration from TOML string
§Errors
Returns an error if the TOML is invalid
§Examples
use bashrs::bash_quality::FormatterConfig;
let toml = r#"
indent_width = 4
use_tabs = true
"#;
let config = FormatterConfig::from_toml(toml).unwrap();
assert_eq!(config.indent_width, 4);
assert!(config.use_tabs);Sourcepub fn should_ignore(&self, path: &str) -> bool
pub fn should_ignore(&self, path: &str) -> bool
Check if a file path should be ignored based on patterns
§Examples
use bashrs::bash_quality::FormatterConfig;
let mut config = FormatterConfig::default();
config.ignore_patterns = vec!["**/test/**".to_string()];
assert!(config.should_ignore("src/test/example.sh"));
assert!(!config.should_ignore("src/main.sh"));Sourcepub fn merge(&mut self, other: Self)
pub fn merge(&mut self, other: Self)
Merge with another configuration, preferring non-default values
§Examples
use bashrs::bash_quality::FormatterConfig;
let mut base = FormatterConfig::default();
let mut override_config = FormatterConfig::default();
override_config.indent_width = 4;
base.merge(override_config);
assert_eq!(base.indent_width, 4);Trait Implementations§
Source§impl Clone for FormatterConfig
impl Clone for FormatterConfig
Source§fn clone(&self) -> FormatterConfig
fn clone(&self) -> FormatterConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FormatterConfig
impl Debug for FormatterConfig
Source§impl Default for FormatterConfig
impl Default for FormatterConfig
Source§impl<'de> Deserialize<'de> for FormatterConfigwhere
FormatterConfig: Default,
impl<'de> Deserialize<'de> for FormatterConfigwhere
FormatterConfig: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for FormatterConfig
impl RefUnwindSafe for FormatterConfig
impl Send for FormatterConfig
impl Sync for FormatterConfig
impl Unpin for FormatterConfig
impl UnwindSafe for FormatterConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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