about summary refs log tree commit diff stats
path: root/pkgs/by-name/ts/tskm/src/main.rs
blob: fe011e27af91092ec28038dc78be715a1036bc34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// nixos-config - My current NixOS configuration
//
// Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This file is part of my nixos-config.
//
// You should have received a copy of the License along with this program.
// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.

use anyhow::Result;
use clap::{CommandFactory, Parser};

use crate::{
    cli::{CliArgs, Command},
    interface::{input, neorg, open, project},
    state::State,
};

pub mod cli;
pub mod interface;
pub mod rofi;
pub mod state;
pub mod task;

fn main() -> Result<(), anyhow::Error> {
    clap_complete::CompleteEnv::with_factory(CliArgs::command).complete();

    let args = CliArgs::parse();

    stderrlog::new()
        .module(module_path!())
        .quiet(args.quiet)
        .show_module_names(true)
        .color(stderrlog::ColorChoice::Auto)
        .verbosity(usize::from(args.verbosity))
        .timestamp(stderrlog::Timestamp::Off)
        .init()
        .expect("Let's just hope that this does not panic");

    let mut state = State::new_rw()?;

    match args.command {
        Command::Inputs { command } => input::handle(command)?,
        Command::Neorg { command } => neorg::handle(command, &mut state)?,
        Command::Open { command } => open::handle(command, &mut state)?,
        Command::Projects { command } => project::handle(command)?,
    }

    Ok(())
}