@@ -192,7 +192,13 @@ def register_pr_parser(subparsers: Any) -> None:
192192
193193 thread_reply_parser = pr_subparsers .add_parser ("thread-reply" , help = "reply to a pull request review thread" )
194194 thread_reply_parser .add_argument ("thread_id" , help = "review thread id, e.g. PRRT_xxx" )
195- thread_reply_parser .add_argument ("--body" , required = True , help = "reply body" )
195+ thread_reply_body_group = thread_reply_parser .add_mutually_exclusive_group (required = True )
196+ thread_reply_body_group .add_argument ("--body" , help = "reply body" )
197+ thread_reply_body_group .add_argument (
198+ "-F" ,
199+ "--body-file" ,
200+ help = "read reply body from file (use `-` to read from standard input)" ,
201+ )
196202 thread_reply_parser .add_argument ("--pr" , help = "PR number/url/branch" )
197203 thread_reply_parser .add_argument ("--repo" , help = "repository in OWNER/REPO format" )
198204 thread_reply_parser .set_defaults (handler = cmd_pr_thread_reply )
@@ -279,7 +285,13 @@ def register_pr_parser(subparsers: Any) -> None:
279285 help = "starting diff side for a multi-line range (defaults to --side)" ,
280286 )
281287 review_comment_parser .add_argument ("--head" , help = "expected PR head sha for stale-snapshot protection" )
282- review_comment_parser .add_argument ("--body" , required = True , help = "review comment body" )
288+ review_comment_body_group = review_comment_parser .add_mutually_exclusive_group (required = True )
289+ review_comment_body_group .add_argument ("--body" , help = "review comment body" )
290+ review_comment_body_group .add_argument (
291+ "-F" ,
292+ "--body-file" ,
293+ help = "read review comment body from file (use `-` to read from standard input)" ,
294+ )
283295 review_comment_parser .add_argument ("--pr" , help = "PR number/url/branch" )
284296 review_comment_parser .add_argument ("--repo" , help = "repository in OWNER/REPO format" )
285297 review_comment_parser .set_defaults (handler = cmd_pr_review_comment )
@@ -290,11 +302,17 @@ def register_pr_parser(subparsers: Any) -> None:
290302 review_suggest_parser .add_argument ("--path" , required = True , help = "file path in pull request" )
291303 review_suggest_parser .add_argument ("--line" , required = True , type = int , help = "line number on selected side" )
292304 review_suggest_parser .add_argument ("--side" , choices = ["RIGHT" , "LEFT" ], default = "RIGHT" , help = "diff side" )
293- review_suggest_parser .add_argument (
305+ review_suggest_body_group = review_suggest_parser .add_mutually_exclusive_group ()
306+ review_suggest_body_group .add_argument (
294307 "--body" ,
295308 default = "Suggested change" ,
296309 help = "review comment body before suggestion block" ,
297310 )
311+ review_suggest_body_group .add_argument (
312+ "-F" ,
313+ "--body-file" ,
314+ help = "read review comment body from file (use `-` to read from standard input)" ,
315+ )
298316 review_suggest_parser .add_argument (
299317 "--suggestion" ,
300318 required = True ,
@@ -332,11 +350,18 @@ def _read_body_file(path: str) -> str:
332350 return Path (path ).read_text (encoding = "utf-8" )
333351
334352
335- def _resolve_review_submit_body (args : Any ) -> str :
353+ def _resolve_body_argument (args : Any , * , default : str = "" ) -> str :
336354 body_file = getattr (args , "body_file" , None )
337355 if body_file :
338356 return _read_body_file (str (body_file ))
339- return str (getattr (args , "body" , "" ))
357+ body = getattr (args , "body" , None )
358+ if body is None :
359+ return default
360+ return str (body )
361+
362+
363+ def _resolve_review_submit_body (args : Any ) -> str :
364+ return _resolve_body_argument (args )
340365
341366
342367def cmd_pr_view (args : Any ) -> int :
@@ -680,7 +705,8 @@ def cmd_pr_thread_reply(args: Any) -> int:
680705 if args .pr is not None :
681706 client .resolve_pull_request (selector = args .pr , repo = args .repo )
682707
683- comment_id = client .reply_review_thread (thread_id = str (args .thread_id ), body = str (args .body ))
708+ body = _resolve_body_argument (args )
709+ comment_id = client .reply_review_thread (thread_id = str (args .thread_id ), body = body )
684710 print (f"thread: { args .thread_id } " )
685711 if comment_id :
686712 print (f"reply_comment_id: { comment_id } " )
@@ -1046,7 +1072,7 @@ def cmd_pr_review_comment(args: Any) -> int:
10461072 side = str (args .side ),
10471073 start_line = start_line ,
10481074 start_side = start_side ,
1049- body = str (args . body ),
1075+ body = _resolve_body_argument (args ),
10501076 )
10511077 print (f"thread: { thread_id } " )
10521078 if comment_id :
@@ -1071,7 +1097,8 @@ def cmd_pr_review_suggest(args: Any) -> int:
10711097 start_side = start_side ,
10721098 )
10731099 suggestion = str (args .suggestion ).rstrip ("\n " )
1074- full_body = f"{ str (args .body ).rstrip ()} \n \n ```suggestion\n { suggestion } \n ```"
1100+ body = _resolve_body_argument (args , default = "Suggested change" )
1101+ full_body = f"{ body .rstrip ()} \n \n ```suggestion\n { suggestion } \n ```"
10751102 thread_id , comment_id = client .add_pull_request_review_thread_comment (
10761103 ref = meta .ref ,
10771104 path = str (args .path ),
0 commit comments