Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

OBorce
Copy link
Contributor

@OBorce OBorce commented Feb 10, 2025

Add a startup option for Wallet CLI to disable the output of QR codes in responses.

Closes #1859

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}")
Copy link
Member

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()

Comment on lines 1827 to 1834
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}")
}
}
Copy link
Contributor

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.

Comment on lines 1823 to 1825
fn disabled_qr_code_env() -> bool {
std::env::var("ML_DISABLE_QR").is_ok()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. qr_codes_disabled_via_env ?
  2. 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 var ML_WALLET_NO_QR.

@OBorce OBorce force-pushed the feature/wallet-cli-no-qr-code branch from 229e2bb to 1e77cba Compare February 19, 2025 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add Option to Disable QR Code Output in the Mintlayer wallet-cli
3 participants