2024-10-16 14:26:43 -07:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2024-10-16 14:36:41 -07:00
|
|
|
use colored::*;
|
|
|
|
use clap::{Parser, Subcommand};
|
2024-10-16 14:26:43 -07:00
|
|
|
|
|
|
|
/// Repotool is a tool to manage multiple code repositories
|
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
#[command(version, about)]
|
|
|
|
struct Args {
|
2024-10-16 14:36:41 -07:00
|
|
|
#[command(subcommand)]
|
|
|
|
command: Command,
|
|
|
|
}
|
2024-10-16 14:26:43 -07:00
|
|
|
|
2024-10-16 14:36:41 -07:00
|
|
|
#[derive(Subcommand, Debug)]
|
|
|
|
enum Command {
|
|
|
|
///List all repositories found in the directory tree
|
|
|
|
List {
|
|
|
|
/// Directory to start from
|
|
|
|
#[arg(short, long)]
|
|
|
|
directory: PathBuf,
|
|
|
|
},
|
2024-10-16 14:26:43 -07:00
|
|
|
}
|
|
|
|
|
2024-10-16 14:36:41 -07:00
|
|
|
fn main() -> Result<(), std::io::Error> {
|
2024-10-16 14:26:43 -07:00
|
|
|
let args = Args::parse();
|
2024-10-16 14:36:41 -07:00
|
|
|
match args.command {
|
|
|
|
Command::List { directory } => list_repos(directory)?,
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn list_repos(directory: PathBuf) -> Result<(), std::io::Error> {
|
|
|
|
let canonicalized = std::fs::canonicalize(directory)?;
|
|
|
|
println!("Listing repositories under: {}", canonicalized.display().to_string().yellow());
|
2024-10-16 14:26:43 -07:00
|
|
|
|
2024-10-16 14:36:41 -07:00
|
|
|
Ok(())
|
2024-10-16 14:09:55 -07:00
|
|
|
}
|