about summary refs log tree commit diff
path: root/src/bin
diff options
context:
space:
mode:
authorJonathan Behrens <behrensj@mit.edu>2017-03-30 19:16:06 -0400
committerJonathan Behrens <behrensj@mit.edu>2017-03-30 19:35:58 -0400
commit56da223dc2129bd6623fa69f0b242b48329171aa (patch)
tree7c07b40416d6304318c745c7f21bd7b66ad2ad1e /src/bin
parent36f0402bac2464910b261d08de54e37a0dce5601 (diff)
--file_lines argument now supports "stdin"
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/rustfmt.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/bin/rustfmt.rs b/src/bin/rustfmt.rs
index af6996613bf..0b30a7f8798 100644
--- a/src/bin/rustfmt.rs
+++ b/src/bin/rustfmt.rs
@@ -217,17 +217,16 @@ fn execute(opts: &Options) -> FmtResult<Summary> {
             // write_mode is always Plain for Stdin.
             config.write_mode = WriteMode::Plain;
 
+            // parse file_lines
+            if let Some(ref file_lines) = matches.opt_str("file-lines") {
+                config.file_lines = try!(file_lines.parse());
+            }
+
             Ok(run(Input::Text(input), &config))
         }
-        Operation::Format {
-            mut files,
-            config_path,
-        } => {
+        Operation::Format { files, config_path } => {
             let options = try!(CliOptions::from_matches(&matches));
 
-            // Add any additional files that were specified via `--file-lines`.
-            files.extend(options.file_lines.files().cloned().map(PathBuf::from));
-
             let mut config = Config::default();
             let mut path = None;
             // Load the config path file if provided
@@ -345,9 +344,8 @@ fn determine_operation(matches: &Matches) -> FmtResult<Operation> {
                       Some(dir)
                   });
 
-    // if no file argument is supplied and `--file-lines` is not specified, read from stdin
-    if matches.free.is_empty() && !matches.opt_present("file-lines") {
-
+    // if no file argument is supplied, read from stdin
+    if matches.free.is_empty() {
         let mut buffer = String::new();
         try!(io::stdin().read_to_string(&mut buffer));
 
@@ -357,7 +355,6 @@ fn determine_operation(matches: &Matches) -> FmtResult<Operation> {
                   });
     }
 
-    // We append files from `--file-lines` later in `execute()`.
     let files: Vec<_> = matches.free.iter().map(PathBuf::from).collect();
 
     Ok(Operation::Format {