Conversation
pool2win
left a comment
There was a problem hiding this comment.
Nice work! I left some comments which we will need to address though.
- let's remove eyre as a dep
- let's use config-rs for parsing config else we will end up writing a bunch of code to parse configs.
src/utils.rs
Outdated
| @@ -0,0 +1,13 @@ | |||
| use std::path::PathBuf; | |||
There was a problem hiding this comment.
Missing and copyright identifier
src/utils.rs
Outdated
| @@ -0,0 +1,13 @@ | |||
| use std::path::PathBuf; | |||
|
|
|||
There was a problem hiding this comment.
We should read the bitcoin config from the TUI. In the wireframes we provide a screen to let user choose the config files. Were you planning to switch to it once we got that in place?
There was a problem hiding this comment.
Yes I'll remove it in order to let the user select it
| ] | ||
| } | ||
|
|
||
| pub fn parse_config(path: &Path) -> Result<Vec<ConfigEntry>> { |
There was a problem hiding this comment.
Let's add a bitcoin.conf.sample to the repo and add a unit test to read that config file and assert some of the config options. I think @R27-pixel 's other PR (pending review and merge) has CI support in now, so we can start building on it. I think you will need to setup the a non insta-rs based testing framework to test things.
Cargo.toml
Outdated
|
|
||
| [dependencies] | ||
| anyhow = "1.0.100" | ||
| color-eyre = "0.6.5" |
There was a problem hiding this comment.
Why this dependency? I think we already included anyhow and I wonder if we will create confusion adding a dependency of eyre?
There was a problem hiding this comment.
In the ratatui docs it's used color_eyre
src/config.rs
Outdated
| @@ -0,0 +1,371 @@ | |||
| use color_eyre::Result; | |||
There was a problem hiding this comment.
Missing license and copyright notices. See other files, we are using SPDX identifiers
|
@framicheli we need to rebase on to main. There's a bunch of conflicts we need to resolve. |
pool2win
left a comment
There was a problem hiding this comment.
Looking good but a few problems we need to address.
- Add comments to structs and functions. All of them.
- Add unit test to the config.rs module.
- Separate out all UI changes to a separate PR. This one should be limited to implement config.rs and testing it thoroughly. I can understand the temptation to run using the tui and see it working, but you can push it in a separate PR which comes after this PR. Otherwise it is too much to review and will result in an error during the review process.
| @@ -2,23 +2,168 @@ | |||
| // | |||
There was a problem hiding this comment.
Add comments for all structs and functions.
| let i = match self.list_state.selected() { | ||
| Some(i) => { | ||
| if i >= self.files.len() - 1 { | ||
| 0 | ||
| } else { | ||
| i + 1 | ||
| } | ||
| } | ||
| None => 0, | ||
| }; |
There was a problem hiding this comment.
I think we can replace this condition with saturating_sub
| let i = match self.list_state.selected() { | ||
| Some(i) => { | ||
| if i == 0 { | ||
| self.files.len() - 1 | ||
| } else { | ||
| i - 1 | ||
| } | ||
| } | ||
| None => 0, | ||
| }; |
There was a problem hiding this comment.
Replace with saturating_sub
| } | ||
| } | ||
|
|
||
| pub fn load_config(&mut self, path: &str) -> Result<()> { |
There was a problem hiding this comment.
Add comment for all functions and structs
| @@ -0,0 +1,448 @@ | |||
| // SPDX-FileCopyrightText: 2024 PDM Authors | |||
There was a problem hiding this comment.
This module is doing a lot of heavy lifting, and is important to get right. We should add tests to this module to make sure we can parse a sample config file with default and non default values for all values.
No description provided.