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:
@@ -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 {
|
||||
|
@@ -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",
|
||||
|
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user