File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ license = "MIT"
1414readme = " README.md"
1515repository = " https://github.com/romankoblov/prettydiff"
1616homepage = " https://github.com/romankoblov/prettydiff"
17+ rust-version = " 1.70"
1718
1819[dependencies ]
1920ansi_term.version = " 0.12"
@@ -27,3 +28,6 @@ structopt.optional = true
2728[features ]
2829cli = [" prettytable-rs" , " structopt" ]
2930default = [" cli" ]
31+
32+ [patch .crates-io ]
33+ prettytable-rs = { git = " https://github.com/asomers/prettytable-rs.git" , rev = " 1e2c2d5c3" }
Original file line number Diff line number Diff line change @@ -338,8 +338,7 @@ impl<'a> LineChangeset<'a> {
338338 }
339339
340340 #[ cfg( feature = "prettytable-rs" ) ]
341- /// Prints side-by-side diff in table
342- pub fn prettytable ( & self ) {
341+ fn prettytable_mktable ( & self ) -> prettytable:: Table {
343342 let mut table = format_table:: new ( ) ;
344343 if let Some ( ( old, new) ) = & self . names {
345344 let mut header = vec ! [ ] ;
@@ -395,9 +394,25 @@ impl<'a> LineChangeset<'a> {
395394 table. add_row ( row ! [ old, new] ) ;
396395 }
397396 }
397+ table
398+ }
399+
400+ #[ cfg( feature = "prettytable-rs" ) ]
401+ /// Prints side-by-side diff in table
402+ pub fn prettytable ( & self ) {
403+ let table = self . prettytable_mktable ( ) ;
398404 table. printstd ( ) ;
399405 }
400406
407+ #[ cfg( feature = "prettytable-rs" ) ]
408+ /// Write side-by-side diff in table to any Writer.
409+ pub fn write_prettytable < W > ( & self , f : & mut W ) -> std:: io:: Result < usize >
410+ where W : std:: io:: Write + std:: io:: IsTerminal
411+ {
412+ let table = self . prettytable_mktable ( ) ;
413+ table. print_term ( f)
414+ }
415+
401416 fn remove_color ( & self , a : & str ) -> String {
402417 Colour :: Red . strikethrough ( ) . paint ( a) . to_string ( )
403418 }
You can’t perform that action at this time.
0 commit comments