diff --git a/src/plumbing/main.rs b/src/plumbing/main.rs index f0916449ef1..c458f39d5ab 100644 --- a/src/plumbing/main.rs +++ b/src/plumbing/main.rs @@ -12,6 +12,7 @@ use clap::Parser; use gitoxide_core as core; use gitoxide_core::pack::verify; +use crate::plumbing::options::pack::multi_index; #[cfg(any(feature = "gitoxide-core-async-client", feature = "gitoxide-core-blocking-client"))] use crate::plumbing::options::remote; use crate::{ @@ -376,8 +377,8 @@ pub fn main() -> Result<()> { }, ) .map(|_| ()), - pack::Subcommands::MultiIndex(subcommands) => match subcommands { - pack::multi_index::Subcommands::Verify { multi_index_path } => prepare_and_run( + pack::Subcommands::MultiIndex(multi_index::Platform { multi_index_path, cmd }) => match cmd { + pack::multi_index::Subcommands::Verify => prepare_and_run( "pack-multi-index-verify", verbose, progress, @@ -391,10 +392,7 @@ pub fn main() -> Result<()> { ) }, ), - pack::multi_index::Subcommands::Create { - output_path, - index_paths, - } => prepare_and_run( + pack::multi_index::Subcommands::Create { index_paths } => prepare_and_run( "pack-multi-index-create", verbose, progress, @@ -403,7 +401,7 @@ pub fn main() -> Result<()> { move |progress, _out, _err| { core::pack::multi_index::create( index_paths, - output_path, + multi_index_path, progress, &git_repository::interrupt::IS_INTERRUPTED, object_hash, diff --git a/src/plumbing/options.rs b/src/plumbing/options.rs index 8208d618a1c..b6a7b9aa31c 100644 --- a/src/plumbing/options.rs +++ b/src/plumbing/options.rs @@ -74,8 +74,7 @@ pub mod pack { #[clap(subcommand)] Index(index::Subcommands), /// Subcommands for interacting with multi-pack indices (named "multi-pack-index") - #[clap(subcommand)] - MultiIndex(multi_index::Subcommands), + MultiIndex(multi_index::Platform), /// Create a new pack with a set of objects. Create { #[clap(long, short = 'r')] @@ -255,22 +254,26 @@ pub mod pack { pub mod multi_index { use std::path::PathBuf; + #[derive(Debug, clap::Parser)] + pub struct Platform { + /// The path to the index file. + #[clap(short = 'i', long, default_value = ".git/objects/packs/multi-pack-index")] + pub multi_index_path: PathBuf, + + /// Subcommands + #[clap(subcommand)] + pub cmd: Subcommands, + } + #[derive(Debug, clap::Subcommand)] pub enum Subcommands { /// Verify a multi-index quickly without inspecting objects themselves - Verify { - /// The path to the multi-pack-index to verify. - multi_index_path: PathBuf, - }, - /// Create a multi-pack index from one or more pack index files + Verify, + /// Create a multi-pack index from one or more pack index files, overwriting possibloy existing files. Create { - /// The path to which the multi-index file should be written, overwriting any possibly existing file. + /// Paths to the pack index files to read (with .idx extension). /// /// Note for the multi-index to be useful, it should be side-by-side with the supplied `.idx` files. - #[clap(long, short = 'o')] - output_path: PathBuf, - - /// Paths to the pack index files to read (with .idx extension). #[clap(required = true)] index_paths: Vec, },