Repository: casey/just (rust)

Issue:
Use command-color for shebang recipes
The recent `command-color` flag works nicely for regular just recipes, but it's not used for shebang recipes (e.g. those which start with `#!`).

So if I do `just --command-color purple foo`, it will echo recipe lines in purple if `foo` is a regular recipe, but will still use white if `foo` is a shebang recipe.

Unless anyone thinks this is the desired behavior, I can probably work on a fix for this.

Pull request description:
Enable command color for shebang recipes
Small MR which resolves #1903, Adding `command-color` for shebang recipes. Now if your shebang recipe is prefixed with `@` and you specify a `command-color`, it will use that when printing out the shebang recipe.

Patch:
diff --git a/justfile b/justfile
index 882b8edf..660e3dae 100755
--- a/justfile
+++ b/justfile
@@ -216,6 +216,11 @@ _sh:
   hello='Yo'
   echo "$hello from a shell script!"
 
+_nu:
+  #!/usr/bin/env nu
+  let hellos = ["Greetings", "Yo", "Howdy"]
+  $hellos | each {|el| print $"($el) from a nushell script!" }
+
 _ruby:
   #!/usr/bin/env ruby
   puts "Hello from ruby!"
diff --git a/src/recipe.rs b/src/recipe.rs
index 3ef2843f..93ff6be3 100644
--- a/src/recipe.rs
+++ b/src/recipe.rs
@@ -310,7 +310,14 @@ impl<'src, D> Recipe<'src, D> {
 
     if config.verbosity.loud() && (config.dry_run || self.quiet) {
       for line in &evaluated_lines {
-        eprintln!("{line}");
+        eprintln!(
+          "{}",
+          config
+            .color
+            .command(config.command_color)
+            .stderr()
+            .paint(line)
+        );
       }
     }
 


Test patch:
diff --git a/tests/shebang.rs b/tests/shebang.rs
index 986d0ca6..e5ae23d9 100644
--- a/tests/shebang.rs
+++ b/tests/shebang.rs
@@ -58,6 +58,37 @@ fn simple() {
     .run();
 }
 
+#[test]
+fn echo() {
+  Test::new()
+    .justfile(
+      "
+        @baz:
+          #!/bin/sh
+          echo fizz
+      ",
+    )
+    .stdout("fizz\n")
+    .stderr("#!/bin/sh\necho fizz\n")
+    .run();
+}
+
+#[test]
+fn echo_with_command_color() {
+  Test::new()
+    .justfile(
+      "
+        @baz:
+          #!/bin/sh
+          echo fizz
+      ",
+    )
+    .args(["--color", "always", "--command-color", "purple"])
+    .stdout("fizz\n")
+    .stderr("\u{1b}[1;35m#!/bin/sh\u{1b}[0m\n\u{1b}[1;35mecho fizz\u{1b}[0m\n")
+    .run();
+}
+
 // This test exists to make sure that shebang recipes run correctly.  Although
 // this script is still executed by a shell its behavior depends on the value of
 // a variable and continuing even though a command fails, whereas in plain