mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-14 08:53:52 +01:00
refactor: refactor config
This commit is contained in:
parent
2b331c2862
commit
a26a4a56d8
4 changed files with 65 additions and 96 deletions
|
|
@ -1,6 +1,4 @@
|
|||
use clap::Clap;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::prelude::*;
|
||||
use std::io::{self, Read};
|
||||
|
||||
use copyrat::{config::basic, run, ui::Selection};
|
||||
|
|
@ -25,19 +23,5 @@ fn main() {
|
|||
}
|
||||
|
||||
let Selection { text, .. } = selection.unwrap();
|
||||
|
||||
// Write output to a target_path if provided, else print to original stdout.
|
||||
match opt.target_path {
|
||||
None => println!("{}", text),
|
||||
Some(target) => {
|
||||
let mut file = OpenOptions::new()
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.write(true)
|
||||
.open(target)
|
||||
.expect("Unable to open the target file");
|
||||
|
||||
file.write_all(text.as_bytes()).unwrap();
|
||||
}
|
||||
}
|
||||
println!("{}", text);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue