tas/src/main.rs

80 lines
2.4 KiB
Rust

//! 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/>.
//!
//---------------------------------------------------------------------
// Rustc lints
#![deny(
unused_imports,
unused_qualifications,
rust_2018_idioms,
unsafe_code,
non_ascii_idents
)]
// Clippy lints
#![deny(clippy::all)]
//---------------------------------------------------------------------
use clap::Parser;
use repo::sqlite::SqliteRepo;
use xdg::BaseDirectories;
mod cli;
pub mod domain;
pub mod repo;
fn main() {
let args = cli::Args::parse();
let xdg_dirs = BaseDirectories::with_prefix(env!("CARGO_PKG_NAME")).unwrap();
let repo = match SqliteRepo::new(xdg_dirs) {
Ok(repo) => repo,
Err(err) => return eprintln!("Cannot connect to repository: {err}"),
};
if let Err(err) = repo.upgrade() {
return eprintln!("Cannot upgrade database: {err}");
}
match args.command {
cli::SubCommand::Add(args) => {
cli::add::execute(repo, args);
}
cli::SubCommand::Edit(args) => {
cli::edit::execute(repo, args);
}
cli::SubCommand::Remove(args) => {
cli::remove::execute(repo, args);
}
cli::SubCommand::List(args) => {
cli::list::execute(repo, args);
}
cli::SubCommand::Priority(args) => {
cli::priority::execute(repo, args);
}
cli::SubCommand::Start(args) => {
cli::start::execute(repo, args);
}
cli::SubCommand::Pause => {
cli::pause::execute(repo);
}
cli::SubCommand::Finish(args) => {
cli::finish::execute(repo, args);
}
cli::SubCommand::Show(args) => {
cli::show::execute(repo, args);
}
}
}