From 56f1daaac2deeff57a8025024934e7adc91aced4 Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Tue, 11 Apr 2023 21:57:23 +0200 Subject: Add docs to all the commands --- src/git.rs | 17 +++++------------ src/parser.rs | 55 ++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/git.rs b/src/git.rs index 1159e7f..3cfaa8c 100644 --- a/src/git.rs +++ b/src/git.rs @@ -196,20 +196,16 @@ pub fn upload_pack(upload_pack_args: &GitUploadPackArgs) -> Result<(), ShackleEr } let mut command = Command::new("git-upload-pack"); - if upload_pack_args.strict { - command.arg("strict"); - } - if upload_pack_args.no_strict { - command.arg("no-strict"); - } + command.arg("--strict"); + if let Some(timeout) = upload_pack_args.timeout { - command.args(["timeout", &timeout.to_string()]); + command.args(["--timeout", &timeout.to_string()]); } if upload_pack_args.stateless_rpc { - command.arg("stateless-rpc"); + command.arg("--stateless-rpc"); } if upload_pack_args.advertise_refs { - command.arg("advertise-refs"); + command.arg("--advertise-refs"); } command.arg(&upload_pack_args.directory); @@ -223,9 +219,6 @@ pub fn receive_pack(receive_pack_args: &GitReceivePackArgs) -> Result<(), Shackl } let mut command = Command::new("git-receive-pack"); - if receive_pack_args.http_backend_info_refs { - command.arg("--http-backend-info-refs"); - } command.arg(&receive_pack_args.directory); command.spawn()?.wait()?; diff --git a/src/parser.rs b/src/parser.rs index 38b88f3..ebd860b 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -8,59 +8,80 @@ use thiserror::Error; #[derive(Parser, Clone, Debug, PartialEq, Eq)] #[command(name = "")] pub enum ShackleCommand { - Exit, + /// Create a new repository + Init(InitArgs), /// List all repositories available List, + /// Sets the description of a repository, as shown in the CLI listing and web interfaces SetDescription(SetDescriptionArgs), + /// Sets the main branch of the repository SetBranch(SetBranchArgs), - Init(InitArgs), + /// Quit the shell + Exit, + /// Server side command required to git fetch from the server GitUploadPack(GitUploadPackArgs), + /// Server side command required by git push to the server GitReceivePack(GitReceivePackArgs), } +#[derive(Parser, Clone, Debug, PartialEq, Eq)] +pub struct InitArgs { + /// Share repository ownership with the specified group (user must be a member of the group) + #[arg(long)] + pub group: Option, + /// Sets the description of the repository, as shown in the CLI listing and web interfaces + #[arg(long)] + pub description: Option, + /// Sets the main branch of the repository + #[arg(long, default_value = "main")] + pub branch: String, + /// Name of the new repository + pub repo_name: String, +} + #[derive(Parser, Clone, Debug, PartialEq, Eq)] pub struct SetDescriptionArgs { + /// The full relative path of the repository, for example git/shuckie/repo.git + #[arg(value_parser = RelativePathParser)] pub directory: PathBuf, + /// The new description pub description: String, } #[derive(Parser, Clone, Debug, PartialEq, Eq)] pub struct SetBranchArgs { + /// The full relative path of the repository, for example git/shuckie/repo.git + #[arg(value_parser = RelativePathParser)] pub directory: PathBuf, + /// The new branch name pub branch: String, } -#[derive(Parser, Clone, Debug, PartialEq, Eq)] -pub struct InitArgs { - #[arg(long)] - pub group: Option, - #[arg(long)] - pub description: Option, - #[arg(long, default_value = "main")] - pub branch: String, - pub repo_name: String, -} - #[derive(Parser, Clone, Debug, PartialEq, Eq)] pub struct GitUploadPackArgs { - #[arg(long)] + /// Do not try /.git/ if is no Git directory + #[arg(long, default_value_t = true)] pub strict: bool, + /// Always try /.git/ if is no Git directory - this argument is accepted for compatability with git, but is ignored #[arg(long)] pub no_strict: bool, + /// Interrupt transfer after seconds of inactivity #[arg(long)] pub timeout: Option, + /// Perform only a single read-write cycle with stdin and stdout #[arg(long)] pub stateless_rpc: bool, + /// Only the initial ref advertisement is output, and the program exits immediately #[arg(long)] pub advertise_refs: bool, + /// The full relative path of the repository for example git/shuckie/repo.git #[arg(value_parser = RelativePathParser)] pub directory: PathBuf, } #[derive(Parser, Clone, Debug, PartialEq, Eq)] pub struct GitReceivePackArgs { - #[arg(long)] - pub http_backend_info_refs: bool, + /// The full relative path of the repository for example git/shuckie/repo.git #[arg(value_parser = RelativePathParser)] pub directory: PathBuf, } @@ -139,7 +160,7 @@ mod test { .parse::() .unwrap(), ShackleCommand::GitUploadPack(GitUploadPackArgs { - strict: false, + strict: true, no_strict: false, timeout: None, stateless_rpc: true, -- cgit v1.2.3