-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor CLI to use clap v3 #197
Comments
I agree that clap is not elegant and that clap_nested is annoying to debug because of meaningless panic messages structopt looks neat |
If we refactor the client, I suggest to rethink the current structure as a whole. Summarizing what we currently have and what I've understood is their functiontionality:
And the problems I see with the current structure:
error: cyclic package dependency: package `substratee-stf v0.8.0 (/home/bhaerdi/ternoa/sgx-keyvault/stf)` depends on itself. Cycle:
package `substratee-stf v0.8.0 (/home/bhaerdi/ternoa/sgx-keyvault/stf)`
... which is depended on by `ternoa-client v0.8.0 (/home/bhaerdi/ternoa/sgx-keyvault/client)`
... which is depended on by `substratee-stf v0.8.0 (/home/bhaerdi/ternoa/sgx-keyvault/stf)`
Makefile:168: recipe for target 'bin/app' failed
Examples of custom client usages:
|
Long story short: Should we really keep the stf/ main differentation? |
Update to Ternoa: After a discussion with brenzi regarding the stf / main client split, we've decided to put all client commands (including the direct worker calls using TrustedOperations) in the client folder. All clap commands will be defined in the main.rs file, where as the functionality will be outsourced to different files, which should make it easy to swap clap with structopt. This decision was based on the argument that ternoa (just like polkadex) does not use the stf. @mullefel you're currently working on the architecture refactoring. What are your thoughts on this issue? |
In my refactoring designs, I also extracted the CLI components from the STF crate to the client crate, just as @haerdib suggests. In addition, I'd also pull out the primitives definitions from https://github.com/integritee-network/worker/blob/master/stf/src/lib.rs into a separate crate, to leave the STF crate with only the STF specific stuff, that is located in https://github.com/integritee-network/worker/blob/master/stf/src/sgx.rs Inside the client, we should make as much code re-usable for the CLI as possible. I've done some of that refactoring in the PolkaDex project (where it's still part of the STF crate). Edit: Design proposal for the STF crate and relation to the client |
I agree with most of your inputs. I have only two remarks:
I generally came to the philosophy lately that I would like to define as much as possible in other crates whereas the main.rs and lib.rs only assemble the code. This forces a modular pattern and rustc even helps you more because it does not allow cyclic deps. ;) |
I totally agree to keep the |
Substrate has changed to use clap v3 instead of structopt: paritytech/substrate#10632. I didn't find a reasoning in the related issues, but either way: Does this affect this issue? |
If clap v3 is better than structopts, it does :P |
|
I believe that the CLI can be greatly simplified if structopt is used for the following reasons:
get_chain_api(matches)
could simply be replaced by:let api = Api::new(ApiOpts.url, ApiOpts.port)
(Note: substrate_api_client does not allow yet to pass url and port separately, see Pass adress and port independently to constructor. scs/substrate-api-client#109)I personally think changing this is going to ease future bugfixing, as the code is much more readable, so it is goint to be worth the effort.
The text was updated successfully, but these errors were encountered: