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/parser.rs | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) (limited to 'src/parser.rs') 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