Initial commit
This commit is contained in:
54
src/main.rs
Normal file
54
src/main.rs
Normal file
@@ -0,0 +1,54 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::{CommandFactory, Parser, command};
|
||||
use clap_complete::{Shell, generate};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about)]
|
||||
struct Args {
|
||||
#[command(subcommand)]
|
||||
command: Command,
|
||||
|
||||
#[arg(short, long)]
|
||||
config: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
enum Command {
|
||||
/// Mirror repositories as specified in the config
|
||||
Rror,
|
||||
|
||||
/// Create a linktree of the latest backups of the repositories, for use with cgit et al.
|
||||
Linktree,
|
||||
|
||||
/// Validate the configuration provided configuration file
|
||||
ValidateConfig,
|
||||
|
||||
/// Generate shell completions
|
||||
#[command(hide = true)]
|
||||
GenerateCompletions(GenerateCompletionArgs),
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
struct GenerateCompletionArgs {
|
||||
#[arg(long, default_value = "bash")]
|
||||
shell: Shell,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
match args.command {
|
||||
Command::GenerateCompletions(args) => {
|
||||
generate(
|
||||
args.shell,
|
||||
&mut Args::command(),
|
||||
"kagami",
|
||||
&mut std::io::stdout(),
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user