@@ -235,7 +235,7 @@ DID-CLI's init-function starts with creating a bunch of directories, if they don
...
@@ -235,7 +235,7 @@ DID-CLI's init-function starts with creating a bunch of directories, if they don
Let's discuss a refactoring we did of the `read()`-function and its corresponding `read`-command.
Let's discuss a refactoring we did of the `read()`-function and its corresponding `read`-command.
**read() before refactor**
**read()-function before refactor**
```rust
```rust
fnread(dcem:&str)->Result<String,std::io::Error>{
fnread(dcem:&str)->Result<String,std::io::Error>{
usestd::io::Write;
usestd::io::Write;
...
@@ -279,7 +279,7 @@ Why did I want to refac this function? Because it does too much. It does more th
...
@@ -279,7 +279,7 @@ Why did I want to refac this function? Because it does too much. It does more th
1. There was no general "store message in file"-command.
1. There was no general "store message in file"-command.
2. There was no easy way to chain commands together, making it difficult to do both the "store to file"- and the "convert file to human readable"-operation at the same time, which led to the "store to file"-operation being bundled together with other commands for convenience.
2. There was no easy way to chain commands together, making it difficult to do both the "store to file"- and the "convert file to human readable"-operation at the same time, which led to the "store to file"-operation being bundled together with other commands for convenience.
***Example of usage BEFORE refactor:***
***Example of using the read-command BEFORE refactor:***
```shell
```shell
$ did read$(cat message-to-me.dcem)# Reads AND stores the message in my wallet
$ did read$(cat message-to-me.dcem)# Reads AND stores the message in my wallet
Hello Jonas!
Hello Jonas!
...
@@ -293,13 +293,13 @@ The solution to my problem was:
...
@@ -293,13 +293,13 @@ The solution to my problem was:
2. Make sure both the `hold` and `read` could optionally read from `stdin`.
2. Make sure both the `hold` and `read` could optionally read from `stdin`.
3. Make sure `hold` command prints its input to `stdout` unmodified, to make it possible to use the output of `hold` as input to `read`.
3. Make sure `hold` command prints its input to `stdout` unmodified, to make it possible to use the output of `hold` as input to `read`.
***Example of usage AFTER refac:***
***Example using the read-command AFTER refactor:***