diff --git a/src/args.rs b/src/args.rs index bf7af75..503e37c 100644 --- a/src/args.rs +++ b/src/args.rs @@ -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, #[structopt(flatten)] diff --git a/src/main.rs b/src/main.rs index 1a38514..b8095b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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(()) }