Repository: dotenv-linter/dotenv-linter (rust)

Issue:
Print a message "Nothing to fix"
### Description

Print a message "Nothing to fix" in the absence of `.env` files for fix.

### Implementation

**Step 1:**

Add a method for [FixOutput](https://github.com/dotenv-linter/dotenv-linter/blob/master/src/common/output/fix.rs#L14) to print the message "Nothing to fix" only if `is_quiet_mode == false`.

**Step 2:**

Call the method from the step 1 when [lines_map](https://github.com/dotenv-linter/dotenv-linter/blob/master/src/lib.rs#L54) is empty.

**Step 3:**

Add integration tests [here](https://github.com/dotenv-linter/dotenv-linter/blob/master/tests/output/fix.rs).

### Example

There aren't `.env` files in the current directory:

```sh
$ dotenv-linter fix
Nothing to fix
```

Pull request description:
Print message if there are no input files for fix subcommand (#385)
<!--
Thank you for your pull request. Please provide a description above and review
the requirements below.

Bug fixes and new features should include tests.
-->
Closes #385

<!-- _Please make sure to review and check all of these items:_ -->

#### ✔ Checklist:
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

- [x] Commit messages have been written in [Conventional Commits](https://www.conventionalcommits.org) format;
- [x] This PR has been added to [CHANGELOG.md](https://github.com/dotenv-linter/dotenv-linter/blob/master/CHANGELOG.md) (at the top of the list);
- [x] Tests for the changes have been added (for bug fixes / features);

<!-- _NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open._ -->


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4d330fc..cfcece8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ ### 🚀 Added
 - Added a Fix Benchmark [#399](https://github.com/dotenv-linter/dotenv-linter/pull/399) ([@a4blue](https://github.com/a4blue))
 - Add benchmark for the compare function
   [#395](https://github.com/dotenv-linter/dotenv-linter/pull/395) ([@FrancisMurillo](https://github.com/FrancisMurillo))
+- Print a message when there are no input files for fix subcommand [#394](https://github.com/dotenv-linter/dotenv-linter/pull/394) ([@mdycz](https://github.com/mdycz))
 - Print a message when there are no input files [#392](https://github.com/dotenv-linter/dotenv-linter/pull/392) ([@jodli](https://github.com/jodli))
 - Add a GitHub Action to compare benchmarks [#378](https://github.com/dotenv-linter/dotenv-linter/pull/378) ([@mgrachev](https://github.com/mgrachev))
 - Add benchmark for the check function [#376](https://github.com/dotenv-linter/dotenv-linter/pull/376) ([@mgrachev](https://github.com/mgrachev))
diff --git a/src/common/output/fix.rs b/src/common/output/fix.rs
index 10b6646..3c1afbb 100644
--- a/src/common/output/fix.rs
+++ b/src/common/output/fix.rs
@@ -54,4 +54,13 @@ pub fn print_warnings(&self, warnings: &[Warning], file_index: usize) {
             println!();
         }
     }
+
+    /// Prints no files found message
+    pub fn print_nothing_to_fix(&self) {
+        if self.is_quiet_mode || self.files_count > 0 {
+            return;
+        }
+
+        println!("Nothing to fix");
+    }
 }
diff --git a/src/lib.rs b/src/lib.rs
index c68af25..ba430a9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -50,9 +50,11 @@ pub fn check(args: &clap::ArgMatches, current_dir: &PathBuf) -> Result<usize, Bo
 pub fn fix(args: &clap::ArgMatches, current_dir: &PathBuf) -> Result<(), Box<dyn Error>> {
     let mut warnings_count = 0;
     let lines_map = get_lines(args, current_dir);
+    let output = FixOutput::new(args.is_present("quiet"), lines_map.len());
 
     // Nothing to fix
     if lines_map.is_empty() {
+        output.print_nothing_to_fix();
         return Ok(());
     }
 
@@ -61,7 +63,6 @@ pub fn fix(args: &clap::ArgMatches, current_dir: &PathBuf) -> Result<(), Box<dyn
         skip_checks = skip.collect();
     }
 
-    let output = FixOutput::new(args.is_present("quiet"), lines_map.len());
     for (index, (fe, strings)) in lines_map.into_iter().enumerate() {
         output.print_processing_info(&fe);
 


Test patch:
diff --git a/tests/output/fix.rs b/tests/output/fix.rs
index ca87dc8..c1ac4d2 100644
--- a/tests/output/fix.rs
+++ b/tests/output/fix.rs
@@ -212,3 +212,27 @@ fn quiet_backup() {
 
     test_dir.close();
 }
+
+#[test]
+fn no_files() {
+    let test_dir = TestDir::new();
+
+    let expected_output = String::from(
+        r#"Nothing to fix
+"#,
+    );
+
+    test_dir.test_command_fix_success(expected_output);
+    test_dir.close()
+}
+
+#[test]
+fn quiet_no_files() {
+    let test_dir = TestDir::new();
+
+    let args = &["--quiet"];
+    let expected_output = String::from("");
+
+    test_dir.test_command_fix_success_with_args(expected_output, args);
+    test_dir.close()
+}