1
1
mirror of https://github.com/Byron/gitoxide synced 2025-10-06 01:52:40 +02:00

Move --all to 'branch list'

This commit is contained in:
Christoph Rüßler
2025-08-30 20:18:56 +02:00
parent e53761181b
commit 6651548f6e
3 changed files with 22 additions and 24 deletions

View File

@@ -1,19 +1,21 @@
use crate::OutputFormat;
pub enum Kind {
Local,
All,
}
pub mod list {
pub enum Kind {
Local,
All,
}
pub struct Options {
pub kind: Kind,
pub struct Options {
pub kind: Kind,
}
}
pub fn list(
repo: gix::Repository,
out: &mut dyn std::io::Write,
format: OutputFormat,
options: Options,
options: list::Options,
) -> anyhow::Result<()> {
if format != OutputFormat::Human {
anyhow::bail!("JSON output isn't supported");
@@ -22,8 +24,8 @@ pub fn list(
let platform = repo.references()?;
let (show_local, show_remotes) = match options.kind {
Kind::Local => (true, false),
Kind::All => (true, true),
list::Kind::Local => (true, false),
list::Kind::All => (true, true),
};
if show_local {

View File

@@ -509,16 +509,12 @@ pub fn main() -> Result<()> {
)
},
),
Subcommands::Branch(platform) => match platform.cmds {
Some(branch::Subcommands::List) | None => {
use core::repository::branch;
Subcommands::Branch(platform) => match platform.cmd {
branch::Subcommands::List { all } => {
use core::repository::branch::list;
let kind = if platform.all {
branch::Kind::All
} else {
branch::Kind::Local
};
let options = branch::Options { kind };
let kind = if all { list::Kind::All } else { list::Kind::Local };
let options = list::Options { kind };
prepare_and_run(
"branch-list",

View File

@@ -243,17 +243,17 @@ pub mod branch {
#[derive(Debug, clap::Parser)]
pub struct Platform {
#[clap(subcommand)]
pub cmds: Option<Subcommands>,
/// List remote-tracking as well as local branches.
#[clap(long, short = 'a')]
pub all: bool,
pub cmd: Subcommands,
}
#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// List all tags.
List,
List {
/// List remote-tracking as well as local branches.
#[clap(long, short = 'a')]
all: bool,
},
}
}