-
Notifications
You must be signed in to change notification settings - Fork 72
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
Extract alias logic into its own implementation. #1369
Conversation
Looks good so far. One suggestion is to move to it's own file under |
Looking good! Just one more suggestion of moving the logic to |
@leighmcculloch @fnando One more thought designwise, is it possibly confusing to users that Cmd {
#[flatten]
contract_id: contract_id::Arg,
/// ...
} and it could be struct Arg {
#[arg(long = "contract-id", required_unless_present = "contract-alias")]
pub contract_id: Option<String>,
#[arg(long = "contract-alias", conflicts_with = "contract-id")]
pub contract_alias: Option<String>,
}
impl Arg {
pub fn resolve(&self, config: &config::Args) -> Result<Strkey::Contract, Error>
} Then for all commands that use the contract id it would be I'm totally fine either way just always am a fan of putting shared logic into flattened Args and not overloading args. |
@willemneal as for As soon as the alias work is done, I plan to update the docs with a section for contract id aliasing, which should also help with adoption. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one piece of feedback inline, but regardless looks good to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fnando Looking really great! Much cleaner for callers to use it. Just one nit.
@willemneal can i get a 👍 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still think that load
is too general, but it's now no longer public so we can address in a future PR. Good work!
What
Extract alias logic into its own implementation.
Why
So we can easily reuse it in other commands (e.g.
contract bindings typescript
will also load the contract id alias).Known limitations
N/A
Storing alias locally
Storing alias globally