Skip to content

Commit

Permalink
refactor (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Mar 6, 2022
1 parent 8198817 commit e6a3d43
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
12 changes: 5 additions & 7 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
27 changes: 15 additions & 12 deletions src/plumbing/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down Expand Up @@ -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<PathBuf>,
},
Expand Down

0 comments on commit e6a3d43

Please sign in to comment.