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
pub mod core;
pub mod func;
pub mod info;
pub mod preview;
pub mod repo;
pub mod shell;
pub mod temp;

use crate::commands;
use crate::prelude::*;

pub fn handle() -> Result<()> {
    use crate::config::Command::*;

    debug!("CONFIG = {:#?}", &*CONFIG);
    match CONFIG.cmd() {
        None => commands::core::main(),

        Some(c) => match c {
            Preview(input) => input.run(),

            PreviewVarStdin(input) => input.run(),

            PreviewVar(input) => input.run(),

            Widget(input) => input.run().context("Failed to print shell widget code"),

            Fn(input) => input
                .run()
                .with_context(|| format!("Failed to execute function `{:#?}`", input.func)),

            Info(input) => input
                .run()
                .with_context(|| format!("Failed to fetch info `{:#?}`", input.info)),

            #[cfg(not(feature = "disable-repo-management"))]
            Repo(input) => input.run(),
        },
    }
}