From fd746ee1ef7bac2b0eab9176c59d6c96dbfde360 Mon Sep 17 00:00:00 2001
From: "a.stevan" <antoine.stevan@isae-supaero.fr>
Date: Wed, 6 Dec 2023 12:15:05 +0100
Subject: [PATCH 1/3] take a path to the bytes

---
 komodo.nu   |  6 +++---
 src/main.rs | 11 +++++++----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/komodo.nu b/komodo.nu
index 92dd8b05..752b87e9 100644
--- a/komodo.nu
+++ b/komodo.nu
@@ -11,7 +11,7 @@ def "nu-complete log-levels" []: nothing -> list<string> {
 }
 
 def run-komodo [
-    args: record<bytes: string, k: int, n: int, do_generate_powers: bool, powers_file: path, do_reconstruct_data: bool, do_verify_blocks: bool, block_files: list<string>>,
+    args: record<bytes: path, k: int, n: int, do_generate_powers: bool, powers_file: path, do_reconstruct_data: bool, do_verify_blocks: bool, block_files: list<string>>,
     --log-level: string,
 ]: nothing -> any {
     with-env {RUST_LOG: $log_level} {
@@ -37,7 +37,7 @@ export def "komodo build" [] {
 }
 
 export def "komodo setup" [
-    bytes: string,
+    bytes: path,
     --powers-file: path = "powers.bin",
     --log-level: string@"nu-complete log-levels" = "INFO"
 ]: nothing -> nothing {
@@ -54,7 +54,7 @@ export def "komodo setup" [
 }
 
 export def "komodo prove" [
-    bytes: string,
+    bytes: path,
     --fec-params: record<k: int, n: int>,
     --powers-file: path = "powers.bin",
     --log-level: string@"nu-complete log-levels" = "INFO"
diff --git a/src/main.rs b/src/main.rs
index 6a733041..cf2ead9b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -24,11 +24,14 @@ const VALIDATE: Validate = Validate::Yes;
 const BLOCK_DIR: &str = "blocks/";
 
 fn parse_args() -> (Vec<u8>, usize, usize, bool, String, bool, bool, Vec<String>) {
-    let bytes = std::env::args()
+    let bytes_path = std::env::args()
         .nth(1)
-        .expect("expected bytes as first positional argument")
-        .as_bytes()
-        .to_vec();
+        .expect("expected path to bytes as first positional argument");
+    let bytes = if bytes_path == "" {
+        vec![]
+    } else {
+        std::fs::read(bytes_path).unwrap()
+    };
     let k: usize = std::env::args()
         .nth(2)
         .expect("expected k as second positional argument")
-- 
GitLab


From 1493db7b1b0905cd4af62de6f75cd461cc299036 Mon Sep 17 00:00:00 2001
From: "a.stevan" <antoine.stevan@isae-supaero.fr>
Date: Wed, 6 Dec 2023 12:27:07 +0100
Subject: [PATCH 2/3] update snippet in the README

---
 README.md | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index cc7c7d7e..9a299f76 100644
--- a/README.md
+++ b/README.md
@@ -18,16 +18,21 @@ use komodo.nu [
 ]
 use binary.nu [ "bytes decode" ]
 
-let bytes = open komodo.nu
+use std assert
 
 komodo build
 
+let bytes = "tests/dragoon_32x32.png"
+
 komodo setup $bytes
 
 komodo prove $bytes --fec-params {k: 3, n: 5}
 komodo verify blocks/0.bin blocks/1.bin
 
-(komodo reconstruct blocks/0.bin blocks/2.bin blocks/3.bin | bytes decode) == $bytes
+let actual = komodo reconstruct blocks/0.bin blocks/2.bin blocks/3.bin | bytes decode
+let expected = open $bytes | into binary | to text | from json | bytes decode
+assert equal $actual $expected
+print "reconstruction was successful"
 ```
 
 `true` should be printed at the end :thumbsup:
-- 
GitLab


From 014b2695feb47bc4b9a48e8248582eb73c5fe944 Mon Sep 17 00:00:00 2001
From: "a.stevan" <antoine.stevan@isae-supaero.fr>
Date: Wed, 6 Dec 2023 12:57:35 +0100
Subject: [PATCH 3/3] make Clippy happy

---
 src/main.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main.rs b/src/main.rs
index cf2ead9b..f35deff1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -27,7 +27,7 @@ fn parse_args() -> (Vec<u8>, usize, usize, bool, String, bool, bool, Vec<String>
     let bytes_path = std::env::args()
         .nth(1)
         .expect("expected path to bytes as first positional argument");
-    let bytes = if bytes_path == "" {
+    let bytes = if bytes_path.is_empty() {
         vec![]
     } else {
         std::fs::read(bytes_path).unwrap()
-- 
GitLab