Skip to content

Commit 38a8350

Browse files
committed
move 'tree' up one level (#331)
1 parent 72876f1 commit 38a8350

File tree

2 files changed

+66
-73
lines changed

2 files changed

+66
-73
lines changed

src/plumbing/main.rs

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use git_repository::bstr::io::BufReadExt;
1313
use gitoxide_core as core;
1414
use gitoxide_core::pack::verify;
1515

16-
use crate::plumbing::options::{commit, revision};
16+
use crate::plumbing::options::{commit, revision, tree};
1717
use crate::{
1818
plumbing::options::{free, repo, Args, Subcommands},
1919
shared::pretty::prepare_and_run,
@@ -548,6 +548,39 @@ pub fn main() -> Result<()> {
548548
},
549549
),
550550
},
551+
Subcommands::Tree { cmd } => match cmd {
552+
tree::Subcommands::Entries {
553+
treeish,
554+
recursive,
555+
extended,
556+
} => prepare_and_run(
557+
"repository-tree-entries",
558+
verbose,
559+
progress,
560+
progress_keep_open,
561+
None,
562+
move |_progress, out, _err| {
563+
core::repository::tree::entries(
564+
repository()?.into(),
565+
treeish.as_deref(),
566+
recursive,
567+
extended,
568+
format,
569+
out,
570+
)
571+
},
572+
),
573+
tree::Subcommands::Info { treeish, extended } => prepare_and_run(
574+
"repository-tree-info",
575+
verbose,
576+
progress,
577+
progress_keep_open,
578+
None,
579+
move |_progress, out, err| {
580+
core::repository::tree::info(repository()?.into(), treeish.as_deref(), extended, format, out, err)
581+
},
582+
),
583+
},
551584
Subcommands::Repository(repo::Platform { cmd }) => match cmd {
552585
repo::Subcommands::Exclude { cmd } => match cmd {
553586
repo::exclude::Subcommands::Query {
@@ -614,46 +647,6 @@ pub fn main() -> Result<()> {
614647
move |_progress, out, err| core::repository::odb::info(repository()?.into(), format, out, err),
615648
),
616649
},
617-
repo::Subcommands::Tree { cmd } => match cmd {
618-
repo::tree::Subcommands::Entries {
619-
treeish,
620-
recursive,
621-
extended,
622-
} => prepare_and_run(
623-
"repository-tree-entries",
624-
verbose,
625-
progress,
626-
progress_keep_open,
627-
None,
628-
move |_progress, out, _err| {
629-
core::repository::tree::entries(
630-
repository()?.into(),
631-
treeish.as_deref(),
632-
recursive,
633-
extended,
634-
format,
635-
out,
636-
)
637-
},
638-
),
639-
repo::tree::Subcommands::Info { treeish, extended } => prepare_and_run(
640-
"repository-tree-info",
641-
verbose,
642-
progress,
643-
progress_keep_open,
644-
None,
645-
move |_progress, out, err| {
646-
core::repository::tree::info(
647-
repository()?.into(),
648-
treeish.as_deref(),
649-
extended,
650-
format,
651-
out,
652-
err,
653-
)
654-
},
655-
),
656-
},
657650
},
658651
}?;
659652
Ok(())

src/plumbing/options.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ pub struct Args {
5151

5252
#[derive(Debug, clap::Subcommand)]
5353
pub enum Subcommands {
54+
/// Interact with tree objects.
55+
Tree {
56+
#[clap(subcommand)]
57+
cmd: tree::Subcommands,
58+
},
5459
/// Interact with commit objects.
5560
Commit {
5661
#[clap(subcommand)]
@@ -73,6 +78,33 @@ pub enum Subcommands {
7378
Free(free::Subcommands),
7479
}
7580

81+
pub mod tree {
82+
#[derive(Debug, clap::Subcommand)]
83+
pub enum Subcommands {
84+
/// Print entries in a given tree
85+
Entries {
86+
/// Traverse the entire tree and its subtrees respectively, not only this tree.
87+
#[clap(long, short = 'r')]
88+
recursive: bool,
89+
90+
/// Provide files size as well. This is expensive as the object is decoded entirely.
91+
#[clap(long, short = 'e')]
92+
extended: bool,
93+
94+
/// The tree to traverse, or the tree at `HEAD` if unspecified.
95+
treeish: Option<String>,
96+
},
97+
/// Provide information about a tree.
98+
Info {
99+
/// Provide files size as well. This is expensive as the object is decoded entirely.
100+
#[clap(long, short = 'e')]
101+
extended: bool,
102+
/// The tree to traverse, or the tree at `HEAD` if unspecified.
103+
treeish: Option<String>,
104+
},
105+
}
106+
}
107+
76108
pub mod commit {
77109
#[derive(Debug, clap::Subcommand)]
78110
pub enum Subcommands {
@@ -532,11 +564,6 @@ pub mod repo {
532564
#[derive(Debug, clap::Subcommand)]
533565
#[clap(visible_alias = "repo")]
534566
pub enum Subcommands {
535-
/// Interact with tree objects.
536-
Tree {
537-
#[clap(subcommand)]
538-
cmd: tree::Subcommands,
539-
},
540567
/// Interact with the object database.
541568
Odb {
542569
#[clap(subcommand)]
@@ -597,31 +624,4 @@ pub mod repo {
597624
Info,
598625
}
599626
}
600-
601-
pub mod tree {
602-
#[derive(Debug, clap::Subcommand)]
603-
pub enum Subcommands {
604-
/// Print entries in a given tree
605-
Entries {
606-
/// Traverse the entire tree and its subtrees respectively, not only this tree.
607-
#[clap(long, short = 'r')]
608-
recursive: bool,
609-
610-
/// Provide files size as well. This is expensive as the object is decoded entirely.
611-
#[clap(long, short = 'e')]
612-
extended: bool,
613-
614-
/// The tree to traverse, or the tree at `HEAD` if unspecified.
615-
treeish: Option<String>,
616-
},
617-
/// Provide information about a tree.
618-
Info {
619-
/// Provide files size as well. This is expensive as the object is decoded entirely.
620-
#[clap(long, short = 'e')]
621-
extended: bool,
622-
/// The tree to traverse, or the tree at `HEAD` if unspecified.
623-
treeish: Option<String>,
624-
},
625-
}
626-
}
627627
}

0 commit comments

Comments
 (0)