Repository: cristianoliveira/funzzy (language: rust)

Issue:
feat: watcher looks for `.watch.yml` or `.watch.yaml` by default



Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index 7f804a1..5a5f6a4 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ find . -name '*.ts' | funzzy 'npx eslint .'
 
 Or complicated as
 ```yaml
-# .watch.yaml
+# .watch.yaml (or .watch.yml)
 # list here all the events and the commands that it should execute
 # TIP: include '.watch.yaml' in your .git/info/exclude to ignore it.
 
diff --git a/src/main.rs b/src/main.rs
index 7df8e7b..81dc755 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -106,50 +106,54 @@ fn main() {
         }
 
         _ => {
-            let filename = if args.flag_config.is_empty() {
-                cli::watch::DEFAULT_FILENAME
+            let rules = if args.flag_config.is_empty() {
+                let default_filename = cli::watch::DEFAULT_FILENAME;
+                match rules::from_file(default_filename) {
+                    Ok(rules) => rules,
+                    Err(err) => match rules::from_file(&default_filename.replace(".yaml", ".yml")) {
+                        Ok(rules) => rules,
+                        Err(_) => error("Failed to read default config file", err),
+                    },
+                }
             } else {
-                &args.flag_config
+                match rules::from_file(&args.flag_config) {
+                    Ok(rules) => rules,
+                    Err(err) => error("Failed to read config file", err),
+                }
             };
 
-            match rules::from_file(filename) {
-                Ok(rules) => {
-                    if !args.flag_target.is_empty() {
-                        let filtered = rules
+            if !args.flag_target.is_empty() {
+                let filtered = rules
+                    .iter()
+                    .cloned()
+                    .filter(|r| r.name.contains(&args.flag_target))
+                    .collect::<Vec<rules::Rules>>();
+
+                if filtered.is_empty() {
+                    let mut output = String::new();
+                    output.push_str(&format!(
+                            "No target found for '{}'\n\n",
+                            args.flag_target
+                            ));
+                    output.push_str("Available targets:\n");
+                    output.push_str(&format!(
+                            "  {}\n",
+                            rules
                             .iter()
                             .cloned()
-                            .filter(|r| r.name.contains(&args.flag_target))
-                            .collect::<Vec<rules::Rules>>();
-
-                        if filtered.is_empty() {
-                            let mut output = String::new();
-                            output.push_str(&format!(
-                                "No target found for '{}'\n\n",
-                                args.flag_target
-                            ));
-                            output.push_str("Available targets:\n");
-                            output.push_str(&format!(
-                                "  {}\n",
-                                rules
-                                    .iter()
-                                    .cloned()
-                                    .map(|r| r.name)
-                                    .collect::<Vec<String>>()
-                                    .join("\n  ")
+                            .map(|r| r.name)
+                            .collect::<Vec<String>>()
+                            .join("\n  ")
                             ));
 
-                            stdout::info(output.as_str());
+                    stdout::info(output.as_str());
 
-                            show("Finished there is no task to run.");
-                        } else {
-                            execute_watch_command(Watches::new(filtered), args.flag_n, args.flag_V);
-                        }
-                    } else {
-                        execute_watch_command(Watches::new(rules), args.flag_n, args.flag_V);
-                    }
+                    show("Finished there is no task to run.");
+                } else {
+                    execute_watch_command(Watches::new(filtered), args.flag_n, args.flag_V);
                 }
-
-                Err(err) => error("Failed to read config file", err),
+            } else {
+                execute_watch_command(Watches::new(rules), args.flag_n, args.flag_V);
             }
         }
     }


Test patch: