mirror of
https://github.com/numtide/treefmt.git
synced 2024-09-11 17:07:44 +03:00
FmtConfig: use more default
The command argument is required, the other ones can be filled with an empty value if unspecified. It makes the code simpler.
This commit is contained in:
parent
7a45f41e2a
commit
dc9886217a
@ -180,8 +180,8 @@ pub fn create_command_context(treefmt_toml: &PathBuf) -> Result<Vec<CmdContext>>
|
||||
.map(|config| {
|
||||
let list_files = glob_to_path(&cwd.to_path_buf(), &config.includes, &config.excludes)?;
|
||||
Ok(CmdContext {
|
||||
command: config.command.clone().unwrap_or_default(),
|
||||
options: config.options.clone().unwrap_or_default(),
|
||||
command: config.command.clone(),
|
||||
options: config.options.clone(),
|
||||
metadata: path_to_filemeta(list_files)?,
|
||||
})
|
||||
})
|
||||
|
@ -25,16 +25,17 @@ pub struct Root {
|
||||
/// Config for each formatters
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct FmtConfig {
|
||||
/// Command formatter to run
|
||||
pub command: String,
|
||||
/// Argument for formatter
|
||||
#[serde(default)]
|
||||
pub options: Vec<String>,
|
||||
/// File or Folder that is included to be formatted
|
||||
#[serde(default)]
|
||||
pub includes: Vec<String>,
|
||||
/// File or Folder that is excluded to be formatted
|
||||
#[serde(default)]
|
||||
pub excludes: Vec<String>,
|
||||
/// Command formatter to run
|
||||
pub command: Option<String>,
|
||||
/// Argument for formatter
|
||||
pub options: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
|
Loading…
Reference in New Issue
Block a user