Skip to content

Commit f4ce5aa

Browse files
committed
fix: make log command default to tree view without requiring mode arg
1 parent 76c06b2 commit f4ce5aa

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

src/main.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,17 @@ fn clap<'a, 'b>() -> App<'a, 'b> {
7373
let log = SubCommand::with_name("log")
7474
.about("Print a visual tree of all pull requests in a stack")
7575
.setting(AppSettings::ArgRequiredElseHelp)
76-
.arg(
77-
Arg::with_name("mode")
78-
.index(1)
79-
.possible_values(&["short"])
80-
.help("Output mode: omit for tree view, 'short' for compact list"),
81-
)
82-
.arg(identifier.clone().index(2))
76+
.arg(identifier.clone())
8377
.arg(exclude.clone())
8478
.arg(repository.clone())
8579
.arg(origin.clone())
80+
.arg(
81+
Arg::with_name("short")
82+
.long("short")
83+
.short("s")
84+
.takes_value(false)
85+
.help("Use compact list format instead of tree view"),
86+
)
8687
.arg(
8788
Arg::with_name("project")
8889
.long("project")
@@ -320,16 +321,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
320321
}
321322

322323
("log", Some(m)) => {
323-
// Handle both positional args: mode (optional) and identifier (required)
324-
// If only one positional arg is given, it's the identifier
325-
let (mode, identifier) = match (m.value_of("mode"), m.value_of("identifier")) {
326-
(Some(mode), Some(id)) => (Some(mode), id),
327-
(Some(id), None) => (None, id), // "mode" position actually has the identifier
328-
(None, Some(id)) => (None, id),
329-
(None, None) => {
330-
panic!("You must provide an identifier to search for");
331-
}
332-
};
324+
let identifier = m.value_of("identifier").unwrap();
333325

334326
// resolve repository with fallback chain
335327
let remote_name = m.value_of("origin").unwrap_or("origin");
@@ -352,7 +344,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
352344
}
353345

354346
// Check if "short" mode
355-
if mode == Some("short") {
347+
if m.is_present("short") {
356348
// Original flat output
357349
for (pr, maybe_parent) in stack {
358350
match maybe_parent {

0 commit comments

Comments
 (0)