edilmedeiros / rust-bcli

Bitcoin CLI in Rust
GNU General Public License v3.0
6 stars 2 forks source link

Notes on project structure #8

Closed itornaza closed 5 months ago

itornaza commented 6 months ago

I would like us to consider the structure of the project and how modules and files are to be organized.

As you have already noticed, I like to have all string literals defined in the constants.rs so all typos and text replacements can be done through a single location and are not mixed up with the real code. Also, code that just assembles output like the interface can either be constructed in the constants be in another module like display.rs.

In order to keep main.rs as clean as possible, I also like to include all command line parsing code in a parse.rs module and all rpc set up from the user options in an rpc.rs module. Finally, all of the command implementations can be included in a commands.rs module.

edilmedeiros commented 6 months ago

Sounds good; no opposition.

Since I'm taking some time to consider the user interface aspects, it doesn't mean I'm the cleanest coder around. So, don't refrain from refactoring my mess until I get on the rails.

Could you open a PR with this setup and refactor the minimal example in the current main.rs so we can see where each stuff goes?

itornaza commented 6 months ago

I am doing the changes and opening the PR soon. I hope I don't mess things up for a change!

tareknaser commented 6 months ago

Just to port my comment from #12

Organization for commands in src/constants.rs looks nice

Maybe later we can have each command set in a separate module instead of one file in commands.rs Each command should be a clap struct containing all the parameters and flags available and implements a handle/run method to handle execution

itornaza commented 6 months ago

I think you are right, the constants.rs is an overkill, enums are more clear. In the next code base update we drop them out!

edilmedeiros commented 5 months ago

12 closes this.