@@ -545,6 +545,12 @@ enum Commands {
545545 #[ command( subcommand) ]
546546 subcommand : PerfSubcommands ,
547547 } ,
548+ /// Display the changelog of user-facing changes.
549+ ///
550+ /// Examples:
551+ /// flyline changelog
552+ #[ command( name = "changelog" , verbatim_doc_comment) ]
553+ Changelog ,
548554}
549555
550556#[ derive( Subcommand , Debug ) ]
@@ -1414,6 +1420,36 @@ impl Flyline {
14141420 crate :: perf:: dump_to_stdout ( ) ;
14151421 }
14161422 } ,
1423+ Some ( Commands :: Changelog ) => {
1424+ let content = crate :: changelog:: CHANGELOG ;
1425+ let pager = std:: env:: var ( "PAGER" ) . unwrap_or_else ( |_| "less" . to_string ( ) ) ;
1426+ let mut parts = pager. split_whitespace ( ) ;
1427+ if let Some ( bin) = parts. next ( ) {
1428+ let args: Vec < & str > = parts. collect ( ) ;
1429+ let mut cmd = std:: process:: Command :: new ( bin) ;
1430+ cmd. args ( & args) ;
1431+ if bin == "less" && args. is_empty ( ) {
1432+ cmd. args ( [ "-R" , "-F" , "-X" ] ) ;
1433+ }
1434+ cmd. stdin ( std:: process:: Stdio :: piped ( ) ) ;
1435+ match cmd. spawn ( ) {
1436+ Ok ( mut child_proc) => {
1437+ if let Some ( mut stdin) = child_proc. stdin . take ( ) {
1438+ use std:: io:: Write ;
1439+ if stdin. write_all ( content. as_bytes ( ) ) . is_ok ( ) {
1440+ drop ( stdin) ; // close stdin to signal EOF to the pager
1441+ let _ = child_proc. wait ( ) ;
1442+ }
1443+ }
1444+ }
1445+ Err ( _) => {
1446+ println ! ( "{}" , content) ;
1447+ }
1448+ }
1449+ } else {
1450+ println ! ( "{}" , content) ;
1451+ }
1452+ }
14171453 }
14181454
14191455 bash_symbols:: BuiltinExitCode :: ExecutionSuccess as c_int
0 commit comments