@@ -7,6 +7,7 @@ use anyhow::Result;
77use clap:: { Parser , Subcommand } ;
88use once_cell:: sync:: Lazy ;
99use regex:: Regex ;
10+ use std:: io:: IsTerminal ;
1011use std:: path:: { Path , PathBuf } ;
1112use tracing:: info;
1213use tracing_subscriber:: EnvFilter ;
@@ -230,6 +231,18 @@ async fn review_command(
230231
231232 let diff_content = if let Some ( path) = diff_path {
232233 tokio:: fs:: read_to_string ( path) . await ?
234+ } else if std:: io:: stdin ( ) . is_terminal ( ) {
235+ if let Ok ( git) = core:: GitIntegration :: new ( "." ) {
236+ let diff = git. get_uncommitted_diff ( ) ?;
237+ if diff. is_empty ( ) {
238+ println ! ( "No changes found" ) ;
239+ return Ok ( ( ) ) ;
240+ }
241+ diff
242+ } else {
243+ println ! ( "No diff provided and not in a git repository." ) ;
244+ return Ok ( ( ) ) ;
245+ }
233246 } else {
234247 use std:: io:: Read ;
235248 let mut buffer = String :: new ( ) ;
@@ -1163,6 +1176,18 @@ async fn smart_review_command(
11631176
11641177 let diff_content = if let Some ( path) = diff_path {
11651178 tokio:: fs:: read_to_string ( path) . await ?
1179+ } else if std:: io:: stdin ( ) . is_terminal ( ) {
1180+ if let Ok ( git) = core:: GitIntegration :: new ( "." ) {
1181+ let diff = git. get_uncommitted_diff ( ) ?;
1182+ if diff. is_empty ( ) {
1183+ println ! ( "No changes found" ) ;
1184+ return Ok ( ( ) ) ;
1185+ }
1186+ diff
1187+ } else {
1188+ println ! ( "No diff provided and not in a git repository." ) ;
1189+ return Ok ( ( ) ) ;
1190+ }
11661191 } else {
11671192 use std:: io:: Read ;
11681193 let mut buffer = String :: new ( ) ;
0 commit comments