diff options
Diffstat (limited to 'pkgs/by-name/ts/tskm/src/interface')
| -rw-r--r-- | pkgs/by-name/ts/tskm/src/interface/input/handle.rs | 7 | ||||
| -rw-r--r-- | pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs | 13 | ||||
| -rw-r--r-- | pkgs/by-name/ts/tskm/src/interface/open/handle.rs | 38 |
3 files changed, 36 insertions, 22 deletions
diff --git a/pkgs/by-name/ts/tskm/src/interface/input/handle.rs b/pkgs/by-name/ts/tskm/src/interface/input/handle.rs index d9904657..cd868f7a 100644 --- a/pkgs/by-name/ts/tskm/src/interface/input/handle.rs +++ b/pkgs/by-name/ts/tskm/src/interface/input/handle.rs @@ -28,7 +28,7 @@ use super::{Input, Tag}; /// # Panics /// When internal assertions fail. #[allow(clippy::too_many_lines)] -pub fn handle(command: InputCommand, state: &mut State) -> Result<()> { +pub async fn handle(command: InputCommand, state: &mut State) -> Result<()> { match command { InputCommand::Add { inputs } => { for input in inputs { @@ -79,10 +79,11 @@ pub fn handle(command: InputCommand, state: &mut State) -> Result<()> { &project, state, Some(all.iter().map(|f| f.url.clone()).collect()), - )?; + ) + .await?; { - use std::io::{Write, stdin, stdout}; + use std::io::{stdin, stdout, Write}; let mut s = String::new(); eprint!("Continue? (y/N) "); diff --git a/pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs b/pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs index 4e433143..12a0180d 100644 --- a/pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs +++ b/pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs @@ -10,19 +10,19 @@ use std::{ env, - fs::{self, File, OpenOptions, read_to_string}, + fs::{self, read_to_string, File, OpenOptions}, io::Write, process::Command, }; -use anyhow::{Context, Result, bail}; +use anyhow::{bail, Context, Result}; use crate::{cli::NeorgCommand, state::State}; -pub fn handle(command: NeorgCommand, state: &mut State) -> Result<()> { +pub async fn handle(command: NeorgCommand, state: &mut State) -> Result<()> { match command { NeorgCommand::Task { task } => { - let project = task.project(state)?; + let project = task.project(state).await?; let base = dirs::data_local_dir() .expect("This should exists") .join("tskm/notes"); @@ -46,7 +46,8 @@ pub fn handle(command: NeorgCommand, state: &mut State) -> Result<()> { let mut file = options.open(&path)?; file.write_all( - format!("* {} (% {})", task.description(state)?, task.uuid()).as_bytes(), + format!("* {} (% {})", task.description(state).await?, task.uuid()) + .as_bytes(), ) .with_context(|| { format!("Failed to write task uuid to file: '{}'", path.display()) @@ -92,7 +93,7 @@ pub fn handle(command: NeorgCommand, state: &mut State) -> Result<()> { } { - task.mark_neorg_data(state)?; + task.mark_neorg_data(state).await?; } } } diff --git a/pkgs/by-name/ts/tskm/src/interface/open/handle.rs b/pkgs/by-name/ts/tskm/src/interface/open/handle.rs index 15f749c5..5b9100bc 100644 --- a/pkgs/by-name/ts/tskm/src/interface/open/handle.rs +++ b/pkgs/by-name/ts/tskm/src/interface/open/handle.rs @@ -10,7 +10,7 @@ use std::str::FromStr; -use anyhow::{Context, Result, bail}; +use anyhow::{bail, Context, Result}; use log::{error, info}; use url::Url; @@ -31,7 +31,7 @@ fn is_empty(project: &task::Project) -> Result<bool> { } #[allow(clippy::too_many_lines)] -pub fn handle(command: OpenCommand, state: &mut State) -> Result<()> { +pub async fn handle(command: OpenCommand, state: &mut State) -> Result<()> { match command { OpenCommand::Review { non_empty } => { for project in task::Project::all().context("Failed to get all project files")? { @@ -43,12 +43,14 @@ pub fn handle(command: OpenCommand, state: &mut State) -> Result<()> { project.to_project_display(), if is_empty { "is empty" } else { "is not empty" } ); - open_in_browser(project, state, None::<Vec<Url>>).with_context(|| { - format!( - "Failed to open project ('{}') in qutebrowser", - project.to_project_display() - ) - })?; + open_in_browser(project, state, None::<Vec<Url>>) + .await + .with_context(|| { + format!( + "Failed to open project ('{}') in qutebrowser", + project.to_project_display() + ) + })?; if project.is_touched() { project.untouch().with_context(|| { @@ -63,9 +65,11 @@ pub fn handle(command: OpenCommand, state: &mut State) -> Result<()> { } OpenCommand::Project { project, urls } => { project.touch().context("Failed to touch project")?; - open_in_browser(&project, state, urls).with_context(|| { - format!("Failed to open project: {}", project.to_project_display()) - })?; + open_in_browser(&project, state, urls) + .await + .with_context(|| { + format!("Failed to open project: {}", project.to_project_display()) + })?; } OpenCommand::Select { urls } => { let selected_project: task::Project = task::Project::from_project_string( @@ -85,7 +89,9 @@ pub fn handle(command: OpenCommand, state: &mut State) -> Result<()> { .touch() .context("Failed to touch project")?; - open_in_browser(&selected_project, state, urls).context("Failed to open project")?; + open_in_browser(&selected_project, state, urls) + .await + .context("Failed to open project")?; } OpenCommand::ListTabs { projects, mode } => { let projects = { @@ -152,7 +158,13 @@ pub fn handle(command: OpenCommand, state: &mut State) -> Result<()> { }; for (active, url) in tabs { - let is_selected = { if active { "🔻 " } else { " " } }; + let is_selected = { + if active { + "🔻 " + } else { + " " + } + }; println!("{is_selected}{url}"); } } |
