diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-11 13:01:24 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-11 13:01:43 +0200 |
commit | 1e5856e56196549104841c14578fd39364360900 (patch) | |
tree | 79405b35388205e14156d8e306e25ca59d6663f6 /pkgs/by-name/ts/tskm/src/interface/input | |
parent | modules/common/projects.json: Remove unneeded ones (diff) | |
download | nixos-config-1e5856e56196549104841c14578fd39364360900.zip |
pkgs/tskm: Port to qutebrowser
Diffstat (limited to 'pkgs/by-name/ts/tskm/src/interface/input')
-rw-r--r-- | pkgs/by-name/ts/tskm/src/interface/input/handle.rs | 44 |
1 files changed, 8 insertions, 36 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 0469870c..839e122f 100644 --- a/pkgs/by-name/ts/tskm/src/interface/input/handle.rs +++ b/pkgs/by-name/ts/tskm/src/interface/input/handle.rs @@ -9,26 +9,25 @@ // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. use std::{ - collections::HashSet, - fs, process, + collections::{HashMap, HashSet}, + fs, str::FromStr, - thread::{self, sleep}, - time::Duration, }; use anyhow::{Context, Result}; -use log::{error, info}; +use log::info; -use crate::cli::InputCommand; +use crate::{browser::open_in_browser, cli::InputCommand, state::State}; -use super::Input; +use super::{Input, Tag}; /// # Errors /// When command handling fails. /// /// # Panics /// When internal assertions fail. -pub fn handle(command: InputCommand) -> Result<()> { +#[allow(clippy::too_many_lines)] +pub fn handle(command: InputCommand, state: &mut State) -> Result<()> { match command { InputCommand::Add { inputs } => { for input in inputs { @@ -67,36 +66,12 @@ pub fn handle(command: InputCommand) -> Result<()> { } } InputCommand::Review { project } => { - let project = project.to_project_display(); - - let local_project = project.clone(); - let handle = thread::spawn(move || { - // We assume that the project is not yet open. - let mut firefox = process::Command::new("firefox") - .args(["-P", local_project.as_str(), "about:newtab"]) - .spawn()?; - - Ok::<_, anyhow::Error>(firefox.wait()?) - }); - // Give Firefox some time to start. - info!("Waiting on firefox to start"); - sleep(Duration::from_secs(4)); - - let project_str = project.as_str(); 'outer: for all in Input::all()?.chunks(100) { info!("Starting review for the first hundred URLs."); for input in all { info!("-> '{input}'"); - let status = process::Command::new("firefox") - .args(["-P", project_str, input.url().to_string().as_str()]) - .status()?; - - if status.success() { - input.remove()?; - } else { - error!("Adding `{input}` to Firefox failed!"); - } + open_in_browser(&project, state, Some(input.url.clone()))?; } { @@ -122,9 +97,6 @@ pub fn handle(command: InputCommand) -> Result<()> { } } } - - info!("Waiting for firefox to stop"); - handle.join().expect("Should be joinable")?; } InputCommand::List { tags } => { let mut tag_set = HashSet::with_capacity(tags.len()); |