@@ -69,7 +69,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6969 let args = Args :: parse ( ) ;
7070
7171 let input_content = match & args. input {
72- Some ( file_path) => fs:: read_to_string ( & file_path)
72+ Some ( file_path) => fs:: read_to_string ( file_path)
7373 . map_err ( |e| format ! ( "Failed to read file {}: {}" , file_path. display( ) , e) ) ?,
7474 None => {
7575 let mut buffer = String :: new ( ) ;
@@ -96,20 +96,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
9696 println ! ( "File is formatted" ) ;
9797 } else {
9898 match ( args. input . as_ref ( ) , args. stdout ) {
99- // If there's no input file, always output to stdout
100- ( None , _) => {
101- print ! ( "{}" , formatted_content) ;
102- }
103- // We're reading from a file and the --stdout flag is on: we output to stdout
104- ( Some ( _) , true ) => {
105- print ! ( "{}" , formatted_content) ;
106- }
107- // We're reading from a file without the --stdout flag: we overwrite the input file
99+ // If we're reading from a file without the --stdout flag: we overwrite the input file
108100 ( Some ( input_file) , false ) => {
109101 fs:: write ( input_file, formatted_content) . map_err ( |e| {
110102 format ! ( "Failed to write to file {}: {}" , input_file. display( ) , e)
111103 } ) ?;
112104 }
105+ // Otherwise we output to stdout
106+ _ => {
107+ print ! ( "{}" , formatted_content) ;
108+ }
113109 }
114110 }
115111
0 commit comments