-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add option to not show QR code in Wallet CLI #1882
base: master
Are you sure you want to change the base?
Conversation
String::new() | ||
} else { | ||
let qr_code_string = qrcode_or_error_string(str_data); | ||
format!("\n\nOr scan the Qr code with it:\n\n{qr_code_string}") |
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.
This code is very context dependant and it's quite easy to break formatting here when used incorrectly from outside. I'd duplicate some code but do this in place.
It's possible to write it in a more compact way with no_qr.then().unwrap_or_else()
fn optional_qrcode_or_error_string(str_data: &str, no_qr: bool) -> String { | ||
if no_qr { | ||
String::new() | ||
} else { | ||
let qr_code_string = qrcode_or_error_string(str_data); | ||
format!("\n\nOr scan the Qr code with it:\n\n{qr_code_string}") | ||
} | ||
} |
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.
I don't like this function either, because it's very specific (due to the message) and yet has a super generic name. Let's remove it.
fn disabled_qr_code_env() -> bool { | ||
std::env::var("ML_DISABLE_QR").is_ok() | ||
} |
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.
qr_codes_disabled_via_env
?- This is actually redundant, because we add env vars for all command line arguments via the
clap
machinery. E.g. your no--no-qr
option can be controlled by the env varML_WALLET_NO_QR
.
229e2bb
to
1e77cba
Compare
Add a startup option for Wallet CLI to disable the output of QR codes in responses.
Closes #1859