//! Copyright (C) 2022, Dmitriy Pleshevskiy //! //! tas is free software: you can redistribute it and/or modify //! it under the terms of the GNU General Public License as published by //! the Free Software Foundation, either version 3 of the License, or //! (at your option) any later version. //! //! tas is distributed in the hope that it will be useful, //! but WITHOUT ANY WARRANTY; without even the implied warranty of //! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //! GNU General Public License for more details. //! //! You should have received a copy of the GNU General Public License //! along with tas. If not, see . //! use crate::{ cli::print_task_detail, repo::{self, Repository}, }; #[derive(clap::Args)] pub struct Args { #[clap(short, long)] open: bool, idx: Option, } pub fn execute(repo: impl Repository, args: Args) { let task = match repo.start_task(args.idx.unwrap_or(1)) { Ok(task) => task, Err(repo::Error::NotFound) => return eprintln!("Task not found"), Err(err) => return eprintln!("Cannot start task: {}", err), }; println!("The task was started successfully"); print_task_detail(&task); if let (Some(link), true) = (task.link.as_ref(), args.open) { log::debug!("opening link..."); std::process::Command::new("xdg-open") .arg(link) .spawn() .expect("failed to start"); log::debug!("opened"); } /* println!("starting..."); println!("-- on start hook found"); println!("-- running..."); println!("> curl ..."); println!("-- status was changed to \"In progress\" successfuly"); */ }