non-terminal use now forces path behavior

This commit is contained in:
Valerie Wolfe 2023-08-09 17:33:34 -04:00
parent 9aa168cadf
commit 499d6c6ac5

View file

@ -2,6 +2,7 @@ use std::{
env::{ current_dir, var },
error::Error,
fs::read_to_string,
io::{ stdout, IsTerminal },
path::PathBuf,
process::{
Command,
@ -81,6 +82,8 @@ fn main() -> Result<(), Box<dyn Error>>{
if target.is_none() { error::no_args(); }
let is_terminal = stdout().is_terminal();
let prop_path = section.get("path");
// handle dir flag
if flag_dir {
@ -100,7 +103,7 @@ fn main() -> Result<(), Box<dyn Error>>{
return Ok(());
}
// handle path flag
if flag_path {
if flag_path || !is_terminal {
if prop_path.is_none() { error::no_property(&fullname, "path"); }
let i_file_path = prop_path.unwrap().as_str().unwrap();
let file_path = if i_file_path.starts_with("~") { i_file_path.replace("~", &home_dir) } else { i_file_path.to_string() };