From 3f4c8ddb73251c706ab49e9528b115f8fed39065 Mon Sep 17 00:00:00 2001
From: STEVAN Antoine <antoine.stevan@isae-supaero.fr>
Date: Fri, 31 May 2024 08:33:20 +0000
Subject: [PATCH] add `inbreeding list` (dragoon/komodo!135)

wait for
- !134

## description
assuming !134 has been merged, this MR allows to run something like
```bash
inbreeding list | input list --fuzzy | inbreeding load $in | inbreeding plot
```
which will fuzzy find the available experiments and then plot it after load :ok_hand:
---
 bins/inbreeding/list.nu | 16 ++++++++++++++++
 bins/inbreeding/load.nu | 16 ++--------------
 bins/inbreeding/mod.nu  |  1 +
 3 files changed, 19 insertions(+), 14 deletions(-)
 create mode 100644 bins/inbreeding/list.nu

diff --git a/bins/inbreeding/list.nu b/bins/inbreeding/list.nu
new file mode 100644
index 00000000..208b541a
--- /dev/null
+++ b/bins/inbreeding/list.nu
@@ -0,0 +1,16 @@
+use consts.nu
+use path.nu [ "remove-cache-prefix" ]
+
+# return experiment names following `$ARG_EXPERIMENT_FORMAT`
+export def main []: nothing -> list<string> {
+    $consts.CACHE
+        | path join '*' '*'
+        | into glob
+        | ls $in
+        | get name
+        | each { remove-cache-prefix }
+        | parse --regex $consts.FULL_EXPERIMENT_FORMAT
+        | reject strategy
+        | each { values | str join '-' }
+        | uniq
+}
diff --git a/bins/inbreeding/load.nu b/bins/inbreeding/load.nu
index c14284c1..595604bc 100644
--- a/bins/inbreeding/load.nu
+++ b/bins/inbreeding/load.nu
@@ -2,22 +2,10 @@ use consts.nu
 use path.nu [ "remove-cache-prefix" ]
 use ../../.nushell error "error throw"
 
-# return experiment names following `$ARG_EXPERIMENT_FORMAT`
-def get-experiments []: nothing -> list<string> {
-    $consts.CACHE
-        | path join '*' '*'
-        | into glob
-        | ls $in
-        | get name
-        | each { remove-cache-prefix }
-        | parse --regex $consts.FULL_EXPERIMENT_FORMAT
-        | reject strategy
-        | each { values | str join '-' }
-        | uniq
-}
+use list.nu
 
 export def main [
-    experiment: string@get-experiments,
+    experiment: string@list,
 ]: [
     nothing -> record<
         experiment: record<k: int, n: int, nb_bytes: int, env: string>,
diff --git a/bins/inbreeding/mod.nu b/bins/inbreeding/mod.nu
index 4059fa7c..15e876c6 100644
--- a/bins/inbreeding/mod.nu
+++ b/bins/inbreeding/mod.nu
@@ -2,5 +2,6 @@ export use build.nu
 export use watch.nu
 export use run.nu
 export use inspect.nu
+export use list.nu
 export use load.nu
 export use plot.nu
-- 
GitLab