2024-07-25 09:02:43 +01:00
|
|
|
//
|
2024-08-12 21:25:24 +01:00
|
|
|
#![allow(clippy::module_name_repetitions)]
|
|
|
|
|
2024-08-03 12:53:59 +01:00
|
|
|
mod alerts;
|
2024-07-27 18:51:05 +01:00
|
|
|
mod file_watcher;
|
2024-07-28 13:35:26 +01:00
|
|
|
mod forge;
|
2024-04-06 18:39:20 +01:00
|
|
|
mod init;
|
2024-07-28 08:58:32 +01:00
|
|
|
mod repo;
|
2024-07-27 08:11:52 +01:00
|
|
|
mod server;
|
2024-08-10 08:30:23 +01:00
|
|
|
|
|
|
|
#[cfg(feature = "tui")]
|
|
|
|
mod tui;
|
2024-04-06 18:39:20 +01:00
|
|
|
|
2024-05-14 07:58:28 +01:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests;
|
2024-08-10 08:30:23 +01:00
|
|
|
mod webhook;
|
2024-05-14 07:58:28 +01:00
|
|
|
|
2024-07-26 06:49:09 +01:00
|
|
|
use git_next_core::git;
|
|
|
|
|
2024-04-28 08:05:09 +01:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2024-04-06 18:26:08 +01:00
|
|
|
use clap::Parser;
|
2024-08-12 21:25:24 +01:00
|
|
|
use color_eyre::Result;
|
2024-04-28 08:05:09 +01:00
|
|
|
use kxio::{fs, network::Network};
|
2024-04-06 18:26:08 +01:00
|
|
|
|
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
#[clap(version = clap::crate_version!(), author = clap::crate_authors!(), about = clap::crate_description!())]
|
|
|
|
struct Commands {
|
|
|
|
#[clap(subcommand)]
|
|
|
|
command: Command,
|
|
|
|
}
|
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
enum Command {
|
|
|
|
Init,
|
|
|
|
#[clap(subcommand)]
|
|
|
|
Server(Server),
|
|
|
|
}
|
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
enum Server {
|
|
|
|
Init,
|
2024-08-10 08:30:23 +01:00
|
|
|
Start {
|
|
|
|
/// Display a UI (experimental)
|
|
|
|
#[cfg(feature = "tui")]
|
|
|
|
#[arg(long, required = false)]
|
|
|
|
ui: bool,
|
|
|
|
},
|
2024-04-06 18:26:08 +01:00
|
|
|
}
|
2024-04-12 12:58:07 +01:00
|
|
|
|
2024-07-30 10:52:05 +01:00
|
|
|
fn main() -> Result<()> {
|
2024-04-28 08:05:09 +01:00
|
|
|
let fs = fs::new(PathBuf::default());
|
2024-04-09 10:44:01 +01:00
|
|
|
let net = Network::new_real();
|
2024-07-26 06:49:09 +01:00
|
|
|
let repository_factory = git::repository::factory::real();
|
2024-04-06 18:26:08 +01:00
|
|
|
let commands = Commands::parse();
|
|
|
|
|
|
|
|
match commands.command {
|
2024-09-01 13:10:14 +01:00
|
|
|
Command::Init => init::run(&fs),
|
2024-04-06 18:26:08 +01:00
|
|
|
Command::Server(server) => match server {
|
2024-09-01 13:10:14 +01:00
|
|
|
Server::Init => server::init(&fs),
|
2024-08-10 08:30:23 +01:00
|
|
|
#[cfg(not(feature = "tui"))]
|
2024-09-01 13:10:14 +01:00
|
|
|
Server::Start {} => server::start(
|
|
|
|
false,
|
|
|
|
fs,
|
|
|
|
net,
|
|
|
|
repository_factory,
|
|
|
|
std::time::Duration::from_secs(10),
|
|
|
|
),
|
2024-08-10 08:30:23 +01:00
|
|
|
#[cfg(feature = "tui")]
|
2024-09-01 13:10:14 +01:00
|
|
|
Server::Start { ui } => server::start(
|
|
|
|
ui,
|
|
|
|
fs,
|
|
|
|
net,
|
|
|
|
repository_factory,
|
|
|
|
std::time::Duration::from_secs(10),
|
|
|
|
),
|
2024-04-06 18:26:08 +01:00
|
|
|
},
|
|
|
|
}
|
2024-04-06 17:39:56 +01:00
|
|
|
}
|