mod git_utils;
mod ops;
mod pid;
mod store;
use clap::{Parser, Subcommand};
use std::path::PathBuf;
use std::process;
#[derive(Parser)]
#[command(name = "git-cloak")]
#[command(bin_name = "git-cloak")]
#[command(about = "The Invisible Layer for Your Repositories", long_about = None)]
#[command(version)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Track {
file: PathBuf,
target_path: Option<PathBuf>,
},
Untrack {
file_in_project: PathBuf,
},
Move {
old_target: PathBuf,
new_target: PathBuf,
},
Inject,
Eject,
Status,
Projects,
Relink,
Clean,
Run {
#[arg(last = true)]
command: Vec<String>,
},
InstallHooks,
}
fn run(cmd: &Commands) -> Result<(), ops::CloakError> {
match cmd {
Commands::Track { file, target_path } => {
ops::track(file, target_path.as_deref())
}
Commands::Untrack { file_in_project } => ops::untrack(file_in_project),
Commands::Inject => ops::inject(),
Commands::Eject => ops::eject(),
Commands::Status => ops::status(),
Commands::Projects => ops::projects(),
_ => {
todo!("Command not yet implemented.");
}
}
}
fn main() {
let cli = Cli::parse();
if let Err(e) = run(&cli.command) {
eprintln!("error: {e}");
process::exit(1);
}
}