git-next/crates/cli/src/main.rs
Paul Campbell 9ca532a2b4
All checks were successful
Rust / build (push) Successful in 2m4s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
refactor: merge file-watcher-crate into cli crate
2024-07-27 18:51:05 +01:00

54 lines
1.1 KiB
Rust

//
mod file_watcher;
mod init;
mod server;
#[cfg(test)]
mod tests;
use git_next_core::git;
use std::path::PathBuf;
use clap::Parser;
use kxio::{fs, network::Network};
#[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,
Start,
}
fn main() {
let fs = fs::new(PathBuf::default());
let net = Network::new_real();
let repository_factory = git::repository::factory::real();
let commands = Commands::parse();
match commands.command {
Command::Init => {
init::run(fs);
}
Command::Server(server) => match server {
Server::Init => {
server::init(fs);
}
Server::Start => {
let sleep_duration = std::time::Duration::from_secs(10);
server::start(fs, net, repository_factory, sleep_duration);
}
},
}
}