tas/src/cli.rs

68 lines
1.8 KiB
Rust
Raw Normal View History

2022-08-05 14:11:24 +03:00
//! 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;
2022-08-05 22:05:22 +03:00
pub mod add;
2022-08-05 21:57:34 +03:00
pub mod edit;
pub mod finish;
2022-08-05 18:25:01 +03:00
pub mod list;
pub mod pause;
2022-08-05 18:19:12 +03:00
pub mod priority;
2022-08-05 18:32:16 +03:00
pub mod remove;
pub mod show;
pub mod start;
2022-08-05 13:44:52 +03:00
#[derive(clap::Parser)]
2022-08-05 00:08:27 +03:00
#[clap(author, version, about = "Experemental task manager")]
pub struct Args {
#[clap(subcommand)]
pub command: SubCommand,
}
2022-08-05 13:44:52 +03:00
#[derive(clap::Subcommand)]
2022-08-05 00:08:27 +03:00
pub enum SubCommand {
2022-08-05 22:05:22 +03:00
Add(self::add::Args),
2022-08-05 21:57:34 +03:00
Edit(self::edit::Args),
#[clap(visible_alias("rm"))]
2022-08-05 18:32:16 +03:00
Remove(self::remove::Args),
2022-08-05 18:19:12 +03:00
Priority(self::priority::Args),
#[clap(visible_alias("ls"))]
2022-08-05 13:44:52 +03:00
List,
#[clap(visible_alias("st"))]
Start(self::start::Args),
2022-08-05 13:44:52 +03:00
Pause,
Finish(self::finish::Args),
#[clap(visible_alias("sh"))]
Show(self::show::Args),
2022-08-05 10:42:35 +03:00
}
pub fn print_task_detail(task: &domain::Task) {
print!(" ");
if let Some(group) = task.group.as_ref() {
print!("[{}]: ", group);
}
println!("{}", task.name);
if let Some(link) = task.link.as_ref() {
println!(" link: {}", link);
}
2022-08-16 22:24:21 +03:00
if let Some(path) = task.path.as_ref() {
println!(" path: {}", path.to_string_lossy());
}
}