Skip to content

Commit

Permalink
move 'tree' up one level (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jul 22, 2022
1 parent 72876f1 commit 38a8350
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 73 deletions.
75 changes: 34 additions & 41 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use git_repository::bstr::io::BufReadExt;
use gitoxide_core as core;
use gitoxide_core::pack::verify;

use crate::plumbing::options::{commit, revision};
use crate::plumbing::options::{commit, revision, tree};
use crate::{
plumbing::options::{free, repo, Args, Subcommands},
shared::pretty::prepare_and_run,
Expand Down Expand Up @@ -548,6 +548,39 @@ pub fn main() -> Result<()> {
},
),
},
Subcommands::Tree { cmd } => match cmd {
tree::Subcommands::Entries {
treeish,
recursive,
extended,
} => prepare_and_run(
"repository-tree-entries",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, _err| {
core::repository::tree::entries(
repository()?.into(),
treeish.as_deref(),
recursive,
extended,
format,
out,
)
},
),
tree::Subcommands::Info { treeish, extended } => prepare_and_run(
"repository-tree-info",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, err| {
core::repository::tree::info(repository()?.into(), treeish.as_deref(), extended, format, out, err)
},
),
},
Subcommands::Repository(repo::Platform { cmd }) => match cmd {
repo::Subcommands::Exclude { cmd } => match cmd {
repo::exclude::Subcommands::Query {
Expand Down Expand Up @@ -614,46 +647,6 @@ pub fn main() -> Result<()> {
move |_progress, out, err| core::repository::odb::info(repository()?.into(), format, out, err),
),
},
repo::Subcommands::Tree { cmd } => match cmd {
repo::tree::Subcommands::Entries {
treeish,
recursive,
extended,
} => prepare_and_run(
"repository-tree-entries",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, _err| {
core::repository::tree::entries(
repository()?.into(),
treeish.as_deref(),
recursive,
extended,
format,
out,
)
},
),
repo::tree::Subcommands::Info { treeish, extended } => prepare_and_run(
"repository-tree-info",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, err| {
core::repository::tree::info(
repository()?.into(),
treeish.as_deref(),
extended,
format,
out,
err,
)
},
),
},
},
}?;
Ok(())
Expand Down
64 changes: 32 additions & 32 deletions src/plumbing/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ pub struct Args {

#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Interact with tree objects.
Tree {
#[clap(subcommand)]
cmd: tree::Subcommands,
},
/// Interact with commit objects.
Commit {
#[clap(subcommand)]
Expand All @@ -73,6 +78,33 @@ pub enum Subcommands {
Free(free::Subcommands),
}

pub mod tree {
#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Print entries in a given tree
Entries {
/// Traverse the entire tree and its subtrees respectively, not only this tree.
#[clap(long, short = 'r')]
recursive: bool,

/// Provide files size as well. This is expensive as the object is decoded entirely.
#[clap(long, short = 'e')]
extended: bool,

/// The tree to traverse, or the tree at `HEAD` if unspecified.
treeish: Option<String>,
},
/// Provide information about a tree.
Info {
/// Provide files size as well. This is expensive as the object is decoded entirely.
#[clap(long, short = 'e')]
extended: bool,
/// The tree to traverse, or the tree at `HEAD` if unspecified.
treeish: Option<String>,
},
}
}

pub mod commit {
#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
Expand Down Expand Up @@ -532,11 +564,6 @@ pub mod repo {
#[derive(Debug, clap::Subcommand)]
#[clap(visible_alias = "repo")]
pub enum Subcommands {
/// Interact with tree objects.
Tree {
#[clap(subcommand)]
cmd: tree::Subcommands,
},
/// Interact with the object database.
Odb {
#[clap(subcommand)]
Expand Down Expand Up @@ -597,31 +624,4 @@ pub mod repo {
Info,
}
}

pub mod tree {
#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Print entries in a given tree
Entries {
/// Traverse the entire tree and its subtrees respectively, not only this tree.
#[clap(long, short = 'r')]
recursive: bool,

/// Provide files size as well. This is expensive as the object is decoded entirely.
#[clap(long, short = 'e')]
extended: bool,

/// The tree to traverse, or the tree at `HEAD` if unspecified.
treeish: Option<String>,
},
/// Provide information about a tree.
Info {
/// Provide files size as well. This is expensive as the object is decoded entirely.
#[clap(long, short = 'e')]
extended: bool,
/// The tree to traverse, or the tree at `HEAD` if unspecified.
treeish: Option<String>,
},
}
}
}

0 comments on commit 38a8350

Please sign in to comment.