summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-04-11 21:57:23 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-04-11 21:57:23 +0200
commit56f1daaac2deeff57a8025024934e7adc91aced4 (patch)
tree69ea1faf835e01e416ab554608c917c5f3ab1486
parente6ed91d0efab436c8a1ca4b6f701b6a9a4d96ccd (diff)
Add docs to all the commands
-rw-r--r--readme.org2
-rw-r--r--src/git.rs17
-rw-r--r--src/parser.rs55
3 files changed, 44 insertions, 30 deletions
diff --git a/readme.org b/readme.org
index a63a3d9..d448589 100644
--- a/readme.org
+++ b/readme.org
@@ -42,7 +42,7 @@ Pijul.
- [X] Change ~git-init~ name to just be ~init~. Later, the ~git~ part will be an
option which defaults to git.
- [X] set the main branch of a repo
-- [ ] help docs on all the commands
+- [X] help docs on all the commands
** Post-MVP
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<String>,
+ /// Sets the description of the repository, as shown in the CLI listing and web interfaces
+ #[arg(long)]
+ pub description: Option<String>,
+ /// 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<String>,
- #[arg(long)]
- pub description: Option<String>,
- #[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 <directory>/.git/ if <directory> is no Git directory
+ #[arg(long, default_value_t = true)]
pub strict: bool,
+ /// Always try <directory>/.git/ if <directory> is no Git directory - this argument is accepted for compatability with git, but is ignored
#[arg(long)]
pub no_strict: bool,
+ /// Interrupt transfer after <TIMEOUT> seconds of inactivity
#[arg(long)]
pub timeout: Option<u32>,
+ /// 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::<ShackleCommand>()
.unwrap(),
ShackleCommand::GitUploadPack(GitUploadPackArgs {
- strict: false,
+ strict: true,
no_strict: false,
timeout: None,
stateless_rpc: true,