mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-22 15:42:23 -05:00
feat(config): Use '-' to dump config to stdout
This commit is contained in:
parent
13a93ee8d1
commit
dbac2eff4a
2 changed files with 6 additions and 2 deletions
|
@ -76,7 +76,7 @@ pub(crate) struct Args {
|
|||
pub(crate) words: bool,
|
||||
|
||||
#[structopt(long, group = "mode")]
|
||||
/// Write the current configuration to file.
|
||||
/// Write the current configuration to file with `-` for stdout
|
||||
pub(crate) dump_config: Option<std::path::PathBuf>,
|
||||
|
||||
#[structopt(flatten)]
|
||||
|
|
|
@ -63,7 +63,11 @@ fn run_dump_config(args: &args::Args, output_path: &std::path::Path) -> proc_exi
|
|||
let mut defaulted_config = config::Config::from_defaults();
|
||||
defaulted_config.update(&config);
|
||||
let output = toml::to_string_pretty(&defaulted_config).with_code(proc_exit::Code::FAILURE)?;
|
||||
std::fs::write(output_path, &output)?;
|
||||
if output_path == std::path::Path::new("-") {
|
||||
std::io::stdout().write_all(output.as_bytes())?;
|
||||
} else {
|
||||
std::fs::write(output_path, &output)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue