-
Notifications
You must be signed in to change notification settings - Fork 276
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
API to set parameters through CLI #4820
Comments
I would like to be assigned with this issue to get started with it. Also, can you give me some idea about what sort of paramters are required to be set through CLI? |
@divyaranjan1905 hi, this is the instruction that's used for setting chain-wide parameters: |
@nxsaken Tried looking into surrounding crates to get an idea. Can we make this available to CLI by setting:
On top of this, I guess we also need to import the struct Let me know where I'm off 🙏 |
@divyaranjan1905 you need to add a subcommand to |
@nxsaken Thank you for the reference. From what I understand from there, after adding What I'm doubtful of is that, do I need to create a |
@mversic how should a parameter be parsed from a CLI command? |
@a-zorina can you give us an idea on this? |
Can we try going further with this? |
Let's consider this. The Each of the variants can also subdivide into further variants, for example There is also We could mirror this hierarchy as CLI subcommands and arguments: iroha set sumeragi block_time_ms 2000
iroha set block max_transactions 512
iroha set custom --id my_param --payload "{\"key\":\"value\"}" |
let's talk in terms of how using We could have something like: iroha parameter set sumeragi block_time_ms 2000
iroha parameter get block max_transactions
iroha parameter set my_param "{\"key\":\"value\"}"
iroha parameter get all I don't think that we should differentiate between built-in and custom parameters, but I'm not completely sure if that's technically feasible |
I think it should be possible to define dynamic subcommands with Clap, the builder API may be helpful here, haven't tried that myself. If it's too messy, it's better to leave it and focus on the common case. @divyaranjan1905 I think this should unblock you, don't hesitate to reach out if you get stuck or anything. |
@nxsaken I was thinking along similar lines. I had defined a pub enum Set {
Sumeragi(SumeragiParameter),
Block(BlockParameter),
} And then I can have an Does this look fine? Now that @mversic mentioned about also getting existing parameters, I guess this Moreover, I had a question regarding the CLI usage: In |
Yeah, you'd probably need both #[derive(clap::Subcommand)
enum Parameter {
Get(parameter::Get),
Set(iroha_data_model::Parameter),
}
mod parameter {
#[derive(clap::Subcommand)
enum Get {
All,
#[command(flatten)]
Inner(iroha_data_model::ParameterNoDataFields), // this doesn't exist
}
} You should probably implement some clap-related parsing for Ignore |
@nxsaken I don't think I understand this, |
@divyaranjan1905 so that the user can specify which parameter they want to read (there is no value to provide) |
Okay, got it. I would need to look deeper into |
Here's something weird happening, that either of you might have a clue about @nxsaken @mversic. I am creating an #[derive(Subcommand, Debug)]
pub enum ParamCmd {
#[command(about = "Setting Sumeragi Parameters.")]
Sumeragi(SumeragiCmd),
#[command(about = "Setting Block Parameters.")]
Block(BlockCmd),
#[command(about = "Setting Transaction Parameters.")]
Transaction(TransactionCmd),
#[command(about = "Setting Smart Contract Parameters.")]
SmartContract(SmartContractCmd),
#[command(about = "Setting Custom Parameters.")]
Custom(CustomCmd),
} For each one of these, I have implemented another #[derive(Subcommand, Debug)]
enum SumeragiCmd {
#[command(about = "Set block time in milliseconds.")]
BlockTime {
#[arg(long = "block-time" )]
value: u64,
},
#[command(about = "Set commit time in milliseconds.")]
CommitTime {
#[arg(long = "commit-time")]
value: u64,
}
} With this we now have subcommands, for selecting sumeragi parameter and then choosing which parameter to get/set. The problem is that for some weird reason, I am getting the following error: rustc [E0277]: error[E0277]: the trait bound `SumeragiCmd: clap::Args` is not satisfied
--> client_cli/src/main.rs:1090:18
|
1090 | Sumeragi(SumeragiCmd),
| ^^^^^^^^^^^ the trait `clap::Args` is not implemented for `SumeragiCmd`
|
= help: the following other types implement trait `clap::Args`:
(dyn clap::Args + 'static)
Box<T>
Get
GetKeyValue
ListPermissions
MetadataArgs
MetadataValueArg
ParamCli
and 19 others I was wondering if this would be a |
Also, I get the following error when importing rustc [E0603]: the trait import `Args` is defined here... |
In Importing If you still have the error, could you push the code, and maybe even open a draft PR? It would be easier to diagnose issues that way and exchange feedback. |
Okay, sure. I'll open a draft PR as soon as I can get the overall ideas implemented. |
The thing is, |
I should've specified what "it" is. What I'm saying is make a struct |
We should add support to set parameters through
iroha
CLIThe text was updated successfully, but these errors were encountered: