jensmemesclient/cli/src/util.rs

28 lines
704 B
Rust

use term_table::{Table, TableBuilder, TableStyle};
use tokio::process::Command;
pub async fn open_link(url: &str) -> anyhow::Result<()> {
match std::env::var_os("BROWSER") {
Some(browser) => {
Command::new(&browser).arg(url).status().await?;
},
None => opener::open(&url)?,
}
Ok(())
}
/// returns an empty table with the correct format settings for lists
pub fn list_table<'a>() -> Table<'a> {
TableBuilder::new()
.style(TableStyle::simple())
.separate_rows(false)
.has_top_boarder(false)
.has_bottom_boarder(false)
.build()
}
pub trait IntoTableRow {
fn into_table_row(&self) -> term_table::row::Row;
}