1mod application;
2mod domain;
3mod infrastructure;
4mod usecase;
5
6use std::process::exit;
7
8use crate::infrastructure::{subcommand::Subcommand, subcommands::Commands};
9use clap::{CommandFactory, Parser};
10
11#[derive(Parser, Debug)]
12#[command(name = "gb")]
13#[command(author = "Alex Speranza")]
14#[command(version = env!("CARGO_PKG_VERSION"))]
15#[command(about = "Gitbox (gb) is wrapper for git and it enhance some functionalities.", long_about = None)]
16struct CliParser {
17 #[command(subcommand)]
18 command: Commands,
19}
20
21pub fn run() {
22 let cli = CliParser::parse();
23
24 #[cfg(debug_assertions)]
25 dbg!(&cli.command);
26
27 exit(match &cli.command {
28 Commands::Changelog(c) => c.execute(),
29 Commands::Init(c) => c.execute(),
30 Commands::Complete(c) => {
31 c.print_completion_script(&mut CliParser::command_for_update());
32 0
33 }
34 Commands::Commit(c) => c.execute(),
35 Commands::Describe(c) => c.execute(),
36 Commands::RefreshExtra(c) => c.execute(),
37 Commands::License(c) => c.execute(),
38 Commands::Tree(c) => c.execute(),
39 _ => {
41 eprintln!("Unknown command. See '--help' or subcommand 'help' for available commands");
42 1
43 }
44 });
45}