Skip to content

Commit be13c81

Browse files
committed
feat(tui): allow launching from CLI
1 parent 13ca64c commit be13c81

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

git-cliff/src/args.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ pub struct Args {
354354
hide = !cfg!(feature = "bitbucket"),
355355
)]
356356
pub bitbucket_repo: Option<RemoteValue>,
357+
/// Launches the TUI.
358+
#[arg(long)]
359+
pub tui: bool,
357360
}
358361

359362
/// Custom type for the remote value.

git-cliff/src/main.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ use git_cliff::logger;
44
use git_cliff_core::error::Result;
55
use std::env;
66
use std::fs::File;
7-
use std::io;
7+
use std::io::{
8+
self,
9+
};
10+
use std::os::unix::process::CommandExt;
811
use std::path::Path;
9-
use std::process;
12+
use std::process::{
13+
self,
14+
Command,
15+
Stdio,
16+
};
1017

1118
/// Profiler.
1219
#[cfg(feature = "profiler")]
@@ -15,6 +22,23 @@ mod profiler;
1522
fn main() -> Result<()> {
1623
// Parse the command line arguments
1724
let args = Args::parse();
25+
26+
// Launch the TUI if the flag is set.
27+
if args.tui {
28+
let env_args = env::args().collect::<Vec<String>>();
29+
let error = Command::new("git-cliff-tui")
30+
.stdout(Stdio::inherit())
31+
.args(
32+
&env_args[1..]
33+
.iter()
34+
.filter(|arg| *arg != "--tui")
35+
.collect::<Vec<&String>>(),
36+
)
37+
.exec();
38+
return Err(error.into());
39+
}
40+
41+
// Enable logging.
1842
if args.verbose == 1 {
1943
env::set_var("RUST_LOG", "debug");
2044
} else if args.verbose > 1 {

0 commit comments

Comments
 (0)