@@ -8,7 +8,8 @@ use rsscript::{
88 format_package_lock_json, format_package_lock_reir_json, format_package_lock_toml,
99 format_package_metadata_human, format_package_metadata_json, format_package_metadata_reir_json,
1010 format_package_publish_human, format_package_publish_json, format_package_review_human,
11- format_package_review_json, format_package_tree_human, format_package_tree_json,
11+ format_package_review_json, format_package_review_markdown, format_package_tree_human,
12+ format_package_tree_json,
1213 format_package_tree_reir_json, format_package_vendor_human, format_package_vendor_json,
1314 format_package_vendor_reir_json, lock_package_dir, package_metadata, package_metadata_verify,
1415 package_tree, publish_package_dry_run_with_registry, review_package_dir, vendor_package_dir,
@@ -28,7 +29,11 @@ pub(crate) fn run_package(args: &[String]) -> ExitCode {
2829 match command {
2930 PackageCommand :: Ci { json, path } => run_package_check ( json, path) ,
3031 PackageCommand :: Check { json, path } => run_package_check ( json, path) ,
31- PackageCommand :: Review { json, path } => run_package_review ( json, path) ,
32+ PackageCommand :: Review {
33+ json,
34+ markdown,
35+ path,
36+ } => run_package_review ( json, markdown, path) ,
3237 PackageCommand :: Diff {
3338 json,
3439 old_path,
@@ -67,6 +72,7 @@ pub(crate) enum PackageCommand<'a> {
6772 } ,
6873 Review {
6974 json : bool ,
75+ markdown : bool ,
7076 path : & ' a str ,
7177 } ,
7278 Diff {
@@ -114,6 +120,7 @@ pub(crate) enum PackageCommand<'a> {
114120
115121fn parse_package_args ( args : & [ String ] ) -> Result < PackageCommand < ' _ > , String > {
116122 let mut json = false ;
123+ let mut markdown = false ;
117124 let mut reir = false ;
118125 let mut verify = false ;
119126 let mut dry_run = false ;
@@ -125,6 +132,8 @@ fn parse_package_args(args: &[String]) -> Result<PackageCommand<'_>, String> {
125132 while let Some ( arg) = args. get ( index) {
126133 if arg == "--json" {
127134 json = true ;
135+ } else if arg == "--markdown" {
136+ markdown = true ;
128137 } else if arg == "--reir" {
129138 reir = true ;
130139 } else if arg == "--verify" {
@@ -183,8 +192,16 @@ fn parse_package_args(args: &[String]) -> Result<PackageCommand<'_>, String> {
183192 match ( words. as_slice ( ) , paths. as_slice ( ) ) {
184193 ( [ ] , [ ] ) => Ok ( PackageCommand :: Check { json, path : "." } ) ,
185194 ( [ ] , [ path] ) => Ok ( PackageCommand :: Check { json, path } ) ,
186- ( [ "review" ] , [ ] ) => Ok ( PackageCommand :: Review { json, path : "." } ) ,
187- ( [ "review" ] , [ path] ) => Ok ( PackageCommand :: Review { json, path } ) ,
195+ ( [ "review" ] , [ ] ) => Ok ( PackageCommand :: Review {
196+ json,
197+ markdown,
198+ path : "." ,
199+ } ) ,
200+ ( [ "review" ] , [ path] ) => Ok ( PackageCommand :: Review {
201+ json,
202+ markdown,
203+ path,
204+ } ) ,
188205 ( [ "diff" ] , [ old_path, new_path] ) => Ok ( PackageCommand :: Diff {
189206 json,
190207 old_path,
@@ -333,7 +350,7 @@ pub(crate) fn run_package_check(json: bool, path: &str) -> ExitCode {
333350 }
334351}
335352
336- fn run_package_review ( json : bool , path : & str ) -> ExitCode {
353+ fn run_package_review ( json : bool , markdown : bool , path : & str ) -> ExitCode {
337354 let review = match review_package_dir ( Path :: new ( path) ) {
338355 Ok ( review) => review,
339356 Err ( error) => {
@@ -342,7 +359,9 @@ fn run_package_review(json: bool, path: &str) -> ExitCode {
342359 }
343360 } ;
344361
345- if json {
362+ if markdown {
363+ print ! ( "{}" , format_package_review_markdown( & review) ) ;
364+ } else if json {
346365 println ! ( "{}" , format_package_review_json( & review) ) ;
347366 } else {
348367 print ! ( "{}" , format_package_review_human( & review) ) ;
@@ -664,7 +683,7 @@ mod tests {
664683 let values = args ( & [ "review" , "--json" , "package" ] ) ;
665684 let command = super :: parse_package_args ( & values) . expect ( "review should parse" ) ;
666685 match command {
667- super :: PackageCommand :: Review { json, path } => {
686+ super :: PackageCommand :: Review { json, path, .. } => {
668687 assert ! ( json) ;
669688 assert_eq ! ( path, "package" ) ;
670689 }
0 commit comments