init: use std::include_bytes (#91)

Avoid the big fat string literal
This commit is contained in:
Jonas Chevalier 2021-03-03 10:20:30 +00:00 committed by GitHub
parent 405d83ae5e
commit 6b2d6fca2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 16 deletions

View File

@ -8,22 +8,7 @@ use std::path::Path;
pub fn init_cmd(work_dir: &Path) -> anyhow::Result<()> {
let file_path = work_dir.join(config::FILENAME);
// TODO: detect if file exists
fs::write(
&file_path,
r#"# One CLI to format the code tree - https://github.com/numtide/treefmt
[formatter.mylanguage]
# Formatter to run
command = "command-to-run"
# Command-line arguments for the command
options = []
# Glob pattern of files to include
includes = [ "*.<language-extension>" ]
# Glob patterns of files to exclude
excludes = []
"#,
)
.with_context(|| {
fs::write(&file_path, std::include_bytes!("init_treefmt.toml")).with_context(|| {
format!(
"{} `{}`",
style("Error writing").bold().red(),

View File

@ -0,0 +1,11 @@
# One CLI to format the code tree - https://github.com/numtide/treefmt
[formatter.mylanguage]
# Formatter to run
command = "command-to-run"
# Command-line arguments for the command
options = []
# Glob pattern of files to include
includes = [ "*.<language-extension>" ]
# Glob patterns of files to exclude
excludes = []