parent
e94a9ca351
commit
4cd7087f13
2 changed files with 4 additions and 1 deletions
|
@ -36,6 +36,9 @@ pub struct Args {
|
||||||
#[clap(short = 'f', long, default_value = ".env")]
|
#[clap(short = 'f', long, default_value = ".env")]
|
||||||
pub file: PathBuf,
|
pub file: PathBuf,
|
||||||
|
|
||||||
|
#[clap(short = 'o', long)]
|
||||||
|
pub output: Option<PathBuf>,
|
||||||
|
|
||||||
#[clap(value_parser)]
|
#[clap(value_parser)]
|
||||||
pub section_names: Vec<String>,
|
pub section_names: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ fn main() -> Result<(), Error> {
|
||||||
fn change_env_layout(args: &cli::Args) -> Result<(), Error> {
|
fn change_env_layout(args: &cli::Args) -> Result<(), Error> {
|
||||||
let content = std::fs::read_to_string(&args.file).map_err(|_| Error::OpenFile)?;
|
let content = std::fs::read_to_string(&args.file).map_err(|_| Error::OpenFile)?;
|
||||||
|
|
||||||
let mut writer = File::create(&args.file)
|
let mut writer = File::create(args.output.as_ref().unwrap_or(&args.file))
|
||||||
.map_err(|_| Error::OpenFile)
|
.map_err(|_| Error::OpenFile)
|
||||||
.map(BufWriter::new)?;
|
.map(BufWriter::new)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue