Compare commits
8 Commits
b1059b34aa
...
8c706d63fb
Author | SHA1 | Date |
---|---|---|
Dmitriy Pleshevskiy | 8c706d63fb | |
Dmitriy Pleshevskiy | 3aaaceee49 | |
Dmitriy Pleshevskiy | 925c0cef70 | |
Dmitriy Pleshevskiy | 9837857081 | |
Dmitriy Pleshevskiy | 9674918396 | |
Dmitriy Pleshevskiy | 273d224e04 | |
Dmitriy Pleshevskiy | ced77f9aa2 | |
Dmitriy Pleshevskiy | 66c950f6ab |
|
@ -23,8 +23,8 @@ pub mod list;
|
|||
pub mod pause;
|
||||
pub mod priority;
|
||||
pub mod remove;
|
||||
pub mod show;
|
||||
pub mod start;
|
||||
pub mod status;
|
||||
|
||||
#[derive(clap::Parser)]
|
||||
#[clap(author, version, about = "Experemental task manager")]
|
||||
|
@ -41,12 +41,13 @@ pub enum SubCommand {
|
|||
Remove(self::remove::Args),
|
||||
Priority(self::priority::Args),
|
||||
#[clap(visible_alias("ls"))]
|
||||
List,
|
||||
List(self::list::Args),
|
||||
#[clap(visible_alias("st"))]
|
||||
Start(self::start::Args),
|
||||
Pause,
|
||||
Finish(self::finish::Args),
|
||||
#[clap(visible_alias("st"))]
|
||||
Status(self::status::Args),
|
||||
#[clap(visible_alias("sh"))]
|
||||
Show(self::show::Args),
|
||||
}
|
||||
|
||||
pub fn print_task_detail(task: &domain::Task) {
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
use crate::{
|
||||
cli::print_task_detail,
|
||||
repo::{self, Repository},
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::cli::print_task_detail;
|
||||
|
@ -27,16 +42,6 @@ pub struct Args {
|
|||
}
|
||||
|
||||
pub fn execute(repo: impl Repository, args: Args) {
|
||||
match repo.get_current_task_opt() {
|
||||
Ok(Some(_)) => {
|
||||
return eprintln!("You can edit task only when you don't have an active task, yet")
|
||||
}
|
||||
Err(err) => {
|
||||
return eprintln!("Cannot read current task: {}", err);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let res = repo.update_task(
|
||||
args.idx,
|
||||
repo::UpdateTaskData {
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
use crate::cli::print_task_detail;
|
||||
use crate::repo::{self, Repository};
|
||||
|
||||
|
|
|
@ -1,7 +1,27 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
use crate::domain::CurrentTaskInfo;
|
||||
use crate::repo::Repository;
|
||||
|
||||
pub fn execute(repo: impl Repository) {
|
||||
#[derive(clap::Args)]
|
||||
pub struct Args {
|
||||
groups: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn execute(repo: impl Repository, args: Args) {
|
||||
let tasks = match repo.get_tasks() {
|
||||
Ok(tasks) => tasks,
|
||||
Err(err) => return eprintln!("Cannot read tasks: {}", err),
|
||||
|
@ -14,7 +34,21 @@ pub fn execute(repo: impl Repository) {
|
|||
}
|
||||
};
|
||||
|
||||
for (i, task) in tasks.iter().enumerate() {
|
||||
let groups = args
|
||||
.groups
|
||||
.into_iter()
|
||||
.map(|g| match g.as_str() {
|
||||
"-" => None,
|
||||
_ => Some(g),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let filtered_tasks = tasks
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, t)| groups.is_empty() || groups.contains(&t.group));
|
||||
|
||||
for (i, task) in filtered_tasks {
|
||||
let idx = i + 1;
|
||||
|
||||
match cur_task {
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
use crate::cli::print_task_detail;
|
||||
use crate::repo::{self, Repository};
|
||||
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
use crate::cli::print_task_detail;
|
||||
use crate::repo::{self, Repository};
|
||||
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
use crate::{
|
||||
cli::print_task_detail,
|
||||
repo::{self, Repository},
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
use crate::cli::print_task_detail;
|
||||
use crate::domain::CurrentTaskInfo;
|
||||
use crate::repo::Repository;
|
||||
|
||||
#[derive(clap::Args)]
|
||||
pub struct Args {
|
||||
part: Option<PrintPart>,
|
||||
}
|
||||
|
||||
#[derive(clap::ValueEnum, Clone)]
|
||||
enum PrintPart {
|
||||
Path,
|
||||
Link,
|
||||
}
|
||||
|
||||
impl std::str::FromStr for PrintPart {
|
||||
type Err = &'static str;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"path" => Ok(PrintPart::Path),
|
||||
"link" => Ok(PrintPart::Link),
|
||||
_ => Err(r#"You can display only "path" or "link""#),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn execute(repo: impl Repository, args: Args) {
|
||||
let task = match repo.get_current_task_opt() {
|
||||
Ok(None) => {
|
||||
return eprintln!("You don't have an active task.");
|
||||
}
|
||||
Ok(Some(CurrentTaskInfo { task, .. })) => task,
|
||||
Err(err) => {
|
||||
return eprintln!("Cannot read current task: {}", err);
|
||||
}
|
||||
};
|
||||
|
||||
match args.part {
|
||||
None => {
|
||||
println!("Information about your current task:");
|
||||
print_task_detail(&task);
|
||||
}
|
||||
Some(PrintPart::Path) => {
|
||||
println!(
|
||||
"{}",
|
||||
task.path
|
||||
.unwrap_or_else(|| std::env::current_dir().expect("Cannot get current dir"))
|
||||
.to_string_lossy()
|
||||
)
|
||||
}
|
||||
Some(PrintPart::Link) => {
|
||||
if let Some(link) = task.link {
|
||||
println!("{}", link)
|
||||
} else {
|
||||
eprintln!("The current task doesn't contain link")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,18 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
use crate::{
|
||||
cli::print_task_detail,
|
||||
repo::{self, Repository},
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
use crate::cli::print_task_detail;
|
||||
use crate::domain::CurrentTaskInfo;
|
||||
use crate::repo::Repository;
|
||||
|
||||
#[derive(clap::Args)]
|
||||
pub struct Args {
|
||||
#[clap(long)]
|
||||
print_path: bool,
|
||||
}
|
||||
|
||||
pub fn execute(repo: impl Repository, args: Args) {
|
||||
let task = match repo.get_current_task_opt() {
|
||||
Ok(None) => {
|
||||
return eprintln!("You don't have an active task.");
|
||||
}
|
||||
Ok(Some(CurrentTaskInfo { task, .. })) => task,
|
||||
Err(err) => {
|
||||
return eprintln!("Cannot read current task: {}", err);
|
||||
}
|
||||
};
|
||||
|
||||
if args.print_path {
|
||||
println!(
|
||||
"{}",
|
||||
task.path
|
||||
.unwrap_or_else(|| std::env::current_dir().expect("Cannot get current dir"))
|
||||
.to_string_lossy()
|
||||
)
|
||||
} else {
|
||||
println!("Information about your current task:");
|
||||
print_task_detail(&task);
|
||||
}
|
||||
}
|
|
@ -1,3 +1,18 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub type TaskId = usize;
|
||||
|
|
|
@ -53,8 +53,8 @@ fn main() {
|
|||
cli::SubCommand::Remove(args) => {
|
||||
cli::remove::execute(repo, args);
|
||||
}
|
||||
cli::SubCommand::List => {
|
||||
cli::list::execute(repo);
|
||||
cli::SubCommand::List(args) => {
|
||||
cli::list::execute(repo, args);
|
||||
}
|
||||
cli::SubCommand::Priority(args) => {
|
||||
cli::priority::execute(repo, args);
|
||||
|
@ -68,8 +68,8 @@ fn main() {
|
|||
cli::SubCommand::Finish(args) => {
|
||||
cli::finish::execute(repo, args);
|
||||
}
|
||||
cli::SubCommand::Status(args) => {
|
||||
cli::status::execute(repo, args);
|
||||
cli::SubCommand::Show(args) => {
|
||||
cli::show::execute(repo, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
15
src/repo.rs
15
src/repo.rs
|
@ -1,3 +1,18 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
pub mod fs;
|
||||
pub mod sqlite;
|
||||
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
//! Copyright (C) 2022, Dmitriy Pleshevskiy <dmitriy@ideascup.me>
|
||||
//!
|
||||
//! 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 <https://www.gnu.org/licenses/>.
|
||||
//!
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
|
Loading…
Reference in New Issue