mod indent;
mod max_line_length;
mod newline;
pub use indent::Indent;
pub use max_line_length::MaxLineLength;
pub use newline::NewlineStyle;
use toml_spanner::Toml;
use toml_spanner::helper::display;
use toml_spanner::helper::parse_string;
const SORT_IMPORTS_DEFAULT: bool = true;
const SORT_INPUTS_DEFAULT: bool = false;
const TRAILING_COMMAS_DEFAULT: bool = true;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Toml)]
#[toml(Toml, deny_unknown_fields)]
pub struct Config {
#[toml(default)]
pub indent: Indent,
#[toml(default)]
pub max_line_length: MaxLineLength,
#[toml(default = SORT_IMPORTS_DEFAULT)]
pub sort_imports: bool,
#[toml(default = SORT_INPUTS_DEFAULT)]
pub sort_inputs: bool,
#[toml(default = TRAILING_COMMAS_DEFAULT)]
pub trailing_commas: bool,
#[toml(default, FromToml with = parse_string, ToToml with = display)]
pub newline_style: NewlineStyle,
}
impl Default for Config {
fn default() -> Self {
Self {
indent: Indent::default(),
max_line_length: MaxLineLength::default(),
sort_imports: SORT_IMPORTS_DEFAULT,
sort_inputs: SORT_INPUTS_DEFAULT,
trailing_commas: TRAILING_COMMAS_DEFAULT,
newline_style: NewlineStyle::default(),
}
}
}
impl Config {
pub fn indent(mut self, indent: Indent) -> Self {
self.indent = indent;
self
}
pub fn newline_style(mut self, newline_style: NewlineStyle) -> Self {
self.newline_style = newline_style;
self
}
pub fn max_line_length(mut self, max_line_length: MaxLineLength) -> Self {
self.max_line_length = max_line_length;
self
}
pub fn sort_imports(mut self, sort_imports: bool) -> Self {
self.sort_imports = sort_imports;
self
}
pub fn sort_inputs(mut self, sort_inputs: bool) -> Self {
self.sort_inputs = sort_inputs;
self
}
pub fn trailing_commas(mut self, trailing_commas: bool) -> Self {
self.trailing_commas = trailing_commas;
self
}
}