add wrapper script
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -1,11 +1,10 @@
|
||||
use std::{env::args, io::{self, BufRead, Read, stdin}};
|
||||
use std::{env::args, fs::OpenOptions, io::{self, Read, Write}};
|
||||
|
||||
use ratatui::{
|
||||
DefaultTerminal, Frame, crossterm::event::{self, Event}, layout::{self, Constraint, Layout}, style::{Style, palette::material::{BLACK, WHITE}}, widgets::{Block, BorderType, Paragraph}
|
||||
};
|
||||
|
||||
fn main() -> Result<(), std::io::Error> {
|
||||
// let mut buffer = Vec::new();
|
||||
let mut buffer = String::new();
|
||||
let stdin = io::stdin();
|
||||
let mut handle = stdin.lock();
|
||||
@@ -19,7 +18,15 @@ fn main() -> Result<(), std::io::Error> {
|
||||
ratatui::restore();
|
||||
|
||||
let v = &app.options[app.index];
|
||||
println!("{}", v);
|
||||
|
||||
let args = args();
|
||||
// gets the last arg
|
||||
let path = args.skip(1).fold(String::new(), |_last, next| next);
|
||||
if let Ok(mut file) = OpenOptions::new().write(true).create(false).open(&path) {
|
||||
file.write_all(v.as_bytes()).expect("Could not write all bytes");
|
||||
} else {
|
||||
println!("{v}");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user