From 4edda4b98945baa36fc87c9f5eda8f05d4897284 Mon Sep 17 00:00:00 2001
From: "a.stevan" <antoine.stevan@isae-supaero.fr>
Date: Fri, 31 May 2024 11:09:58 +0200
Subject: [PATCH 1/4] add a script to check syntax

---
 scripts/check-nushell-files.nu | 49 ++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 scripts/check-nushell-files.nu

diff --git a/scripts/check-nushell-files.nu b/scripts/check-nushell-files.nu
new file mode 100644
index 00000000..30e2aeee
--- /dev/null
+++ b/scripts/check-nushell-files.nu
@@ -0,0 +1,49 @@
+let files = [
+    [name,                                 is_module, ignore, reason];
+
+    [bins/inbreeding,                      true,      false,  null],
+    [.nushell,                             true,      false,  null],
+    [tests/cli.nu,                         false,     false,  null],
+    [tests/binary.nu,                      false,     false,  null],
+    [tests/color.nu,                       false,     false,  null],
+    [examples/cli.nu,                      false,     false,  null],
+    [komodo.nu,                            false,     false,  null],
+    [benchmarks/.nushell/commit/run.nu,    false,     false,  null],
+    [benchmarks/.nushell/fec/run.nu,       false,     true,   "fails for some reason..."],
+    [benchmarks/.nushell/recoding/run.nu,  false,     true,   "fails for some reason..."],
+    [benchmarks/.nushell/setup/run.nu,     false,     false,  null],
+    [benchmarks/.nushell/commit/plot.nu,   false,     false,  null],
+    [benchmarks/.nushell/fec/plot.nu,      false,     false,  null],
+    [benchmarks/.nushell/recoding/plot.nu, false,     false,  null],
+    [benchmarks/.nushell/setup/plot.nu,    false,     false,  null],
+]
+
+for f in $files {
+    let path = $env.FILE_PWD | path dirname | path join $f.name
+
+    if $f.ignore {
+        print $"ignore ($f.name): ($f.reason)"
+        continue
+    }
+
+    try {
+        if $f.is_module {
+            nu-check $path --debug --as-module
+        } else {
+            nu-check $path --debug
+        }
+    } catch { |e|
+        let err = $e.debug
+            | ansi strip
+            | parse '{foo}msg: "Found : {msg}", span: {bar}'
+            | into record
+            | get msg
+        error make --unspanned {
+            msg: ([
+                $"($e.msg):",
+                $"    file: ($f.name)",
+                $"    err:  ($err)",
+            ] | str join "\n")
+        }
+    }
+}
-- 
GitLab


From 55d43514e42789429249edea56957069178563c2 Mon Sep 17 00:00:00 2001
From: "a.stevan" <antoine.stevan@isae-supaero.fr>
Date: Fri, 31 May 2024 11:10:12 +0200
Subject: [PATCH 2/4] add it to `make check`

---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index bb44f39c..7b19bfa6 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,7 @@ fmt:
 	cargo fmt --all
 
 check:
+	nu scripts/check-nushell-files.nu
 	cargo check --workspace --all-targets
 
 clippy:
-- 
GitLab


From ae3057198786a3eab777f9b4d32203ff4b1c4ef3 Mon Sep 17 00:00:00 2001
From: "a.stevan" <antoine.stevan@isae-supaero.fr>
Date: Tue, 26 Nov 2024 11:31:49 +0100
Subject: [PATCH 3/4] update check script

---
 scripts/check-nushell-files.nu | 41 ++++++----------------------------
 1 file changed, 7 insertions(+), 34 deletions(-)

diff --git a/scripts/check-nushell-files.nu b/scripts/check-nushell-files.nu
index 30e2aeee..8052b684 100644
--- a/scripts/check-nushell-files.nu
+++ b/scripts/check-nushell-files.nu
@@ -1,48 +1,21 @@
-let files = [
-    [name,                                 is_module, ignore, reason];
-
-    [bins/inbreeding,                      true,      false,  null],
-    [.nushell,                             true,      false,  null],
-    [tests/cli.nu,                         false,     false,  null],
-    [tests/binary.nu,                      false,     false,  null],
-    [tests/color.nu,                       false,     false,  null],
-    [examples/cli.nu,                      false,     false,  null],
-    [komodo.nu,                            false,     false,  null],
-    [benchmarks/.nushell/commit/run.nu,    false,     false,  null],
-    [benchmarks/.nushell/fec/run.nu,       false,     true,   "fails for some reason..."],
-    [benchmarks/.nushell/recoding/run.nu,  false,     true,   "fails for some reason..."],
-    [benchmarks/.nushell/setup/run.nu,     false,     false,  null],
-    [benchmarks/.nushell/commit/plot.nu,   false,     false,  null],
-    [benchmarks/.nushell/fec/plot.nu,      false,     false,  null],
-    [benchmarks/.nushell/recoding/plot.nu, false,     false,  null],
-    [benchmarks/.nushell/setup/plot.nu,    false,     false,  null],
-]
+let files = ^git lf | lines | where { ($in | path parse).extension == "nu" }
 
 for f in $files {
-    let path = $env.FILE_PWD | path dirname | path join $f.name
-
-    if $f.ignore {
-        print $"ignore ($f.name): ($f.reason)"
-        continue
-    }
+    let path = $env.FILE_PWD | path dirname | path join $f
 
     try {
-        if $f.is_module {
-            nu-check $path --debug --as-module
-        } else {
-            nu-check $path --debug
-        }
+        nu-check $path --debug
     } catch { |e|
         let err = $e.debug
             | ansi strip
-            | parse '{foo}msg: "Found : {msg}", span: {bar}'
+            | parse --regex '(.*)msg: "Found : (?<msg>.*)", span: (?<span>.*)'
             | into record
-            | get msg
+
         error make --unspanned {
             msg: ([
                 $"($e.msg):",
-                $"    file: ($f.name)",
-                $"    err:  ($err)",
+                $"    file: ($f)",
+                $"    err:  ($err.msg)",
             ] | str join "\n")
         }
     }
-- 
GitLab


From 129ac719b29c33d09f47fa340e1452e35cab0f65 Mon Sep 17 00:00:00 2001
From: "a.stevan" <antoine.stevan@isae-supaero.fr>
Date: Tue, 26 Nov 2024 11:32:37 +0100
Subject: [PATCH 4/4] add colors

---
 scripts/check-nushell-files.nu | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/check-nushell-files.nu b/scripts/check-nushell-files.nu
index 8052b684..024c6554 100644
--- a/scripts/check-nushell-files.nu
+++ b/scripts/check-nushell-files.nu
@@ -13,8 +13,8 @@ for f in $files {
 
         error make --unspanned {
             msg: ([
-                $"($e.msg):",
-                $"    file: ($f)",
+                $"(ansi red_bold)($e.msg)(ansi reset):",
+                $"    file: (ansi purple)($f)(ansi reset)",
                 $"    err:  ($err.msg)",
             ] | str join "\n")
         }
-- 
GitLab