Rename wprintln to weprintln.

- This change is in preparation for a `stdout` variant.

  - See #342.
This commit is contained in:
Neal H. Walfield 2024-12-03 11:52:47 +01:00
parent fc617dee6b
commit 8902710333
No known key found for this signature in database
GPG Key ID: 6863C9AD5B4D22D3
37 changed files with 721 additions and 721 deletions

View File

@ -92,7 +92,7 @@ pub fn import_certs(sq: &mut Sq, source: &mut Box<dyn BufferedReader<Cookie>>,
Err(e) => {
// The decryption failed, but we should still import the
// Autocrypt header.
wprintln!("Note: Decryption of message failed: {}", e);
weprintln!("Note: Decryption of message failed: {}", e);
return Ok(());
},
};

View File

@ -110,7 +110,7 @@ where 'store: 'rstore
let result = inner();
wprintln!();
weprintln!();
stats.print_summary(&sq)?;
Ok(result?)
@ -163,12 +163,12 @@ fn import_certs(sq: &mut Sq,
if let Err(err) = cert_store.update_by(Arc::new(cert.into()),
stats)
{
wprintln!("Error importing {}, {}: {}",
fingerprint, sanitized_userid, err);
weprintln!("Error importing {}, {}: {}",
fingerprint, sanitized_userid, err);
stats.certs.inc_errors();
continue;
} else {
wprintln!("Imported {}, {}", fingerprint, sanitized_userid);
weprintln!("Imported {}, {}", fingerprint, sanitized_userid);
}
}
@ -178,7 +178,7 @@ fn import_certs(sq: &mut Sq,
Err(errors.pop().ok_or_else(|| anyhow::anyhow!("no cert found"))?)
} else {
for err in errors {
wprintln!("Error parsing input: {}", err);
weprintln!("Error parsing input: {}", err);
}
Ok(())
}
@ -248,15 +248,15 @@ fn import_rev(sq: &mut Sq,
if let Err(err) = cert_store.update_by(Arc::new(cert.into()),
stats)
{
wprintln!("Error importing revocation certificate \
for {}, {}: {}",
fingerprint, sanitized_userid, err);
weprintln!("Error importing revocation certificate \
for {}, {}: {}",
fingerprint, sanitized_userid, err);
stats.certs.inc_errors();
continue;
} else {
wprintln!("Imported revocation certificate \
for {}, {}",
fingerprint, sanitized_userid);
weprintln!("Imported revocation certificate \
for {}, {}",
fingerprint, sanitized_userid);
}
return Ok(());
@ -267,17 +267,17 @@ fn import_rev(sq: &mut Sq,
}
let search: Option<&KeyHandle> = if let Some(bad) = bad.first() {
wprintln!("Appears to be a revocation for {}, \
but the certificate is not available.",
bad);
weprintln!("Appears to be a revocation for {}, \
but the certificate is not available.",
bad);
Some(bad)
} else if ! missing.is_empty() {
wprintln!("Appears to be a revocation for {}, \
but the certificate is not available.",
missing.iter()
.map(|issuer| issuer.to_string())
.collect::<Vec<_>>()
.join(" or "));
weprintln!("Appears to be a revocation for {}, \
but the certificate is not available.",
missing.iter()
.map(|issuer| issuer.to_string())
.collect::<Vec<_>>()
.join(" or "));
Some(missing[0])
} else {
None

View File

@ -274,7 +274,7 @@ pub fn lint(sq: Sq, mut args: Command) -> Result<()> {
found_issue = true;
}
if ! sq.quiet() {
wprintln!($($arg)*);
weprintln!($($arg)*);
}
}
}};
@ -408,14 +408,14 @@ pub fn lint(sq: Sq, mut args: Command) -> Result<()> {
}
Err(err) => {
unfixed_issue += 1;
wprintln!("Certificate {}: \
Failed to update \
revocation certificate \
{:02X}{:02X}: {}",
cert.keyid().to_hex(),
rev.digest_prefix()[0],
rev.digest_prefix()[1],
err);
weprintln!("Certificate {}: \
Failed to update \
revocation certificate \
{:02X}{:02X}: {}",
cert.keyid().to_hex(),
rev.digest_prefix()[0],
rev.digest_prefix()[1],
err);
}
}
}
@ -531,13 +531,13 @@ pub fn lint(sq: Sq, mut args: Command) -> Result<()> {
}
Err(err) => {
unfixed_issue += 1;
wprintln!("Certificate {}: User ID {}: \
Failed to update \
binding signature: {}",
cert.keyid().to_hex(),
String::from_utf8_lossy(
ua.value()),
err);
weprintln!("Certificate {}: User ID {}: \
Failed to update \
binding signature: {}",
cert.keyid().to_hex(),
String::from_utf8_lossy(
ua.value()),
err);
}
}
}
@ -582,12 +582,12 @@ pub fn lint(sq: Sq, mut args: Command) -> Result<()> {
Ok(sig) => updates.push(sig),
Err(err) => {
unfixed_issue += 1;
wprintln!("Certificate {}, key {}: \
Failed to update \
binding signature: {}",
cert.keyid().to_hex(),
ka.keyid().to_hex(),
err);
weprintln!("Certificate {}, key {}: \
Failed to update \
binding signature: {}",
cert.keyid().to_hex(),
ka.keyid().to_hex(),
err);
}
}
}
@ -631,8 +631,8 @@ pub fn lint(sq: Sq, mut args: Command) -> Result<()> {
backsigs.dedup();
if backsigs.len() > 1 {
wprintln!("Warning: multiple cryptographically \
valid backsigs.");
weprintln!("Warning: multiple cryptographically \
valid backsigs.");
}
if backsigs
@ -670,12 +670,12 @@ pub fn lint(sq: Sq, mut args: Command) -> Result<()> {
Ok(sig) => updates.push(sig),
Err(err) => {
unfixed_issue += 1;
wprintln!("Certificate {}, key: {}: \
Failed to update \
binding signature: {}",
cert.keyid().to_hex(),
ka.keyid().to_hex(),
err);
weprintln!("Certificate {}, key: {}: \
Failed to update \
binding signature: {}",
cert.keyid().to_hex(),
ka.keyid().to_hex(),
err);
}
}
}
@ -735,15 +735,15 @@ pub fn lint(sq: Sq, mut args: Command) -> Result<()> {
eprint!("GOOD");
}
}
wprintln!(")");
weprintln!(")");
}};
}
if certs_with_issues > 0 {
wprintln!("Examined {} {}.",
certs_valid + certs_invalid,
pl(certs_valid + certs_invalid,
"certificate", "certificates"));
weprintln!("Examined {} {}.",
certs_valid + certs_invalid,
pl(certs_valid + certs_invalid,
"certificate", "certificates"));
if ! sq.quiet() {
err!(certs_invalid,
@ -752,10 +752,10 @@ pub fn lint(sq: Sq, mut args: Command) -> Result<()> {
pl(certs_invalid, "certificate is", "certificates are"),
pl(certs_invalid, "was", "were"));
if certs_valid > 0 {
wprintln!(" {} {} linted.",
certs_valid,
pl(certs_valid,
"certificate was", "certificates were"));
weprintln!(" {} {} linted.",
certs_valid,
pl(certs_valid,
"certificate was", "certificates were"));
err!(certs_with_issues,
" {} of the {} certificates ({}%) \
{} at least one issue.",
@ -763,22 +763,22 @@ pub fn lint(sq: Sq, mut args: Command) -> Result<()> {
certs_valid + certs_invalid,
certs_with_issues * 100 / (certs_valid + certs_invalid),
pl(certs_with_issues, "has", "have"));
wprintln!("{} of the linted certificates {} revoked.",
certs_revoked,
pl(certs_revoked, "was", "were"));
weprintln!("{} of the linted certificates {} revoked.",
certs_revoked,
pl(certs_revoked, "was", "were"));
err!(certs_with_inadequota_revocations,
" {} of the {} certificates has revocation certificates \
that are weaker than the certificate and should be \
recreated.",
certs_with_inadequota_revocations,
certs_revoked);
wprintln!("{} of the linted certificates {} expired.",
certs_expired,
pl(certs_expired, "was", "were"));
wprintln!("{} of the non-revoked linted {} at least one non-revoked User ID:",
certs_sp_sha1_userids,
pl(certs_sp_sha1_userids,
"certificate has", "certificates have"));
weprintln!("{} of the linted certificates {} expired.",
certs_expired,
pl(certs_expired, "was", "were"));
weprintln!("{} of the non-revoked linted {} at least one non-revoked User ID:",
certs_sp_sha1_userids,
pl(certs_sp_sha1_userids,
"certificate has", "certificates have"));
err!(certs_with_a_sha1_protected_userid,
" {} {} at least one User ID protected by SHA-1.",
certs_with_a_sha1_protected_userid,
@ -788,22 +788,22 @@ pub fn lint(sq: Sq, mut args: Command) -> Result<()> {
certs_with_only_sha1_protected_userids,
pl(certs_with_only_sha1_protected_userids,
"has", "have"));
wprintln!("{} of the non-revoked linted certificates {} at least one \
non-revoked, live subkey:",
certs_with_subkeys,
pl(certs_with_subkeys,
"has", "have"));
weprintln!("{} of the non-revoked linted certificates {} at least one \
non-revoked, live subkey:",
certs_with_subkeys,
pl(certs_with_subkeys,
"has", "have"));
err!(certs_with_a_sha1_protected_binding_sig,
" {} {} at least one non-revoked, live subkey with \
a binding signature that uses SHA-1.",
certs_with_a_sha1_protected_binding_sig,
pl(certs_with_a_sha1_protected_binding_sig,
"has", "have"));
wprintln!("{} of the non-revoked linted certificates {} at least one non-revoked, live, \
weprintln!("{} of the non-revoked linted certificates {} at least one non-revoked, live, \
signing-capable subkey:",
certs_with_signing_subkeys,
pl(certs_with_signing_subkeys,
"has", "have"));
certs_with_signing_subkeys,
pl(certs_with_signing_subkeys,
"has", "have"));
err!(certs_with_sha1_protected_backsig,
" {} {} at least one non-revoked, live, signing-capable subkey \
with a strong binding signature, but a backsig \

View File

@ -35,21 +35,21 @@ fn network(sq: Sq, _: inspect::network::Command) -> Result<()> {
}
// First, sq network search, the most general interface.
wprintln!(initial_indent = " - ", "sq network search");
wprintln!(initial_indent = " - ", "{}",
may_use("WKD", sq.config.network_search_wkd()));
wprintln!(initial_indent = " - ",
"relevant setting: network.search.use-wkd");
weprintln!(initial_indent = " - ", "sq network search");
weprintln!(initial_indent = " - ", "{}",
may_use("WKD", sq.config.network_search_wkd()));
weprintln!(initial_indent = " - ",
"relevant setting: network.search.use-wkd");
if sq.config.network_search_wkd() {
wprintln!(initial_indent = " - ", "see below for impact");
weprintln!(initial_indent = " - ", "see below for impact");
}
wprintln!(initial_indent = " - ", "{}",
may_use("DANE", sq.config.network_search_dane()));
wprintln!(initial_indent = " - ",
"relevant setting: network.search.use-dane");
weprintln!(initial_indent = " - ", "{}",
may_use("DANE", sq.config.network_search_dane()));
weprintln!(initial_indent = " - ",
"relevant setting: network.search.use-dane");
if sq.config.network_search_dane() {
wprintln!(initial_indent = " - ", "see below for impact");
weprintln!(initial_indent = " - ", "see below for impact");
}
let key_servers = sq.config.key_servers(
@ -58,84 +58,84 @@ fn network(sq: Sq, _: inspect::network::Command) -> Result<()> {
.collect::<Vec<_>>();
if key_servers.is_empty() {
wprintln!(initial_indent = " - ",
"will use no key servers by default");
weprintln!(initial_indent = " - ",
"will use no key servers by default");
} else {
wprintln!(initial_indent = " - ",
"will use the following key servers");
weprintln!(initial_indent = " - ",
"will use the following key servers");
for s in &key_servers {
wprintln!(initial_indent = " - ", "{}", s);
weprintln!(initial_indent = " - ", "{}", s);
}
}
wprintln!(initial_indent = " - ",
"relevant setting: network.keyservers");
weprintln!(initial_indent = " - ",
"relevant setting: network.keyservers");
if ! key_servers.is_empty() {
wprintln!(initial_indent = " - ", "see below for impact");
weprintln!(initial_indent = " - ", "see below for impact");
}
if sq.config.network_search_iterations() > 1 {
wprintln!(initial_indent = " - ",
"will iteratively search up to {} steps from \
your original query to discover related \
certificates",
sq.config.network_search_iterations().saturating_sub(1));
wprintln!(initial_indent = " - ",
"this will query certificates that you did not \
request, hopefully finding relevant related \
certificates, but increases the metadata \
leakage and may query \"suspicious\" \
certificates");
weprintln!(initial_indent = " - ",
"will iteratively search up to {} steps from \
your original query to discover related \
certificates",
sq.config.network_search_iterations().saturating_sub(1));
weprintln!(initial_indent = " - ",
"this will query certificates that you did not \
request, hopefully finding relevant related \
certificates, but increases the metadata \
leakage and may query \"suspicious\" \
certificates");
}
// Then, sq network keyserver search.
wprintln!();
wprintln!(initial_indent = " - ", "sq network keyserver search");
weprintln!();
weprintln!(initial_indent = " - ", "sq network keyserver search");
if key_servers.is_empty() {
wprintln!(initial_indent = " - ",
"will use no key servers by default");
weprintln!(initial_indent = " - ",
"will use no key servers by default");
} else {
wprintln!(initial_indent = " - ",
"will use the following key servers");
weprintln!(initial_indent = " - ",
"will use the following key servers");
for s in &key_servers {
wprintln!(initial_indent = " - ", "{}", s);
weprintln!(initial_indent = " - ", "{}", s);
}
}
wprintln!(initial_indent = " - ",
"relevant setting: network.keyservers");
wprintln!(initial_indent = " - ", "impact:");
wprintln!(initial_indent = " - ",
"key servers and their operators can see all requests, \
and learn about your contacts, and track you");
wprintln!(initial_indent = " - ",
"although the traffic is encrypted, network observers \
can use traffic analysis and observe the size of requests \
and responses, and infer information about you and \
your contacts, and track you");
weprintln!(initial_indent = " - ",
"relevant setting: network.keyservers");
weprintln!(initial_indent = " - ", "impact:");
weprintln!(initial_indent = " - ",
"key servers and their operators can see all requests, \
and learn about your contacts, and track you");
weprintln!(initial_indent = " - ",
"although the traffic is encrypted, network observers \
can use traffic analysis and observe the size of requests \
and responses, and infer information about you and \
your contacts, and track you");
// Then, sq network wkd search.
wprintln!();
wprintln!(initial_indent = " - ", "sq network wkd search");
wprintln!(initial_indent = " - ", "impact:");
wprintln!(initial_indent = " - ",
"WKD servers and their operators can see all requests, \
and learn about your contacts, and track you");
wprintln!(initial_indent = " - ",
"although the traffic is encrypted, network observers \
can use traffic analysis, and observe the size of requests \
and responses, and infer information about you and \
your contacts, and possibly track you");
weprintln!();
weprintln!(initial_indent = " - ", "sq network wkd search");
weprintln!(initial_indent = " - ", "impact:");
weprintln!(initial_indent = " - ",
"WKD servers and their operators can see all requests, \
and learn about your contacts, and track you");
weprintln!(initial_indent = " - ",
"although the traffic is encrypted, network observers \
can use traffic analysis, and observe the size of requests \
and responses, and infer information about you and \
your contacts, and possibly track you");
// Then, sq network dane search.
wprintln!();
wprintln!(initial_indent = " - ", "sq network dane search");
wprintln!(initial_indent = " - ", "impact:");
wprintln!(initial_indent = " - ",
"DNS servers and their operators can see all requests, \
and learn about your contacts, and track you");
wprintln!(initial_indent = " - ",
"the traffic is not encrypted, network observers \
can see all requests, and learn about your contacts, \
and track you");
weprintln!();
weprintln!(initial_indent = " - ", "sq network dane search");
weprintln!(initial_indent = " - ", "impact:");
weprintln!(initial_indent = " - ",
"DNS servers and their operators can see all requests, \
and learn about your contacts, and track you");
weprintln!(initial_indent = " - ",
"the traffic is not encrypted, network observers \
can see all requests, and learn about your contacts, \
and track you");
Ok(())
}
@ -147,18 +147,18 @@ fn paths(sq: Sq, _: inspect::paths::Command) -> Result<()> {
// Formats a path.
let mut p = |path: &Path, name: &str, description: &str| -> Result<()> {
if dirty {
wprintln!();
weprintln!();
}
dirty = true;
wprintln!(initial_indent = " - ", "{}", name);
wprintln!(initial_indent = " - ", "{}", path.display());
weprintln!(initial_indent = " - ", "{}", name);
weprintln!(initial_indent = " - ", "{}", path.display());
if ! path.exists() {
wprintln!(initial_indent = " - ", "does not exist");
weprintln!(initial_indent = " - ", "does not exist");
}
wprintln!(initial_indent = " - ", "{}", description);
weprintln!(initial_indent = " - ", "{}", description);
Ok(())
};

View File

@ -69,9 +69,9 @@ pub fn dispatch(sq: Sq, command: cli::decrypt::Command) -> Result<()> {
if result.is_err() {
if let Some(path) = command.output.path() {
if let Err(err) = std::fs::remove_file(path) {
wprintln!("Decryption failed, failed to remove \
output saved to {}: {}",
path.display(), err);
weprintln!("Decryption failed, failed to remove \
output saved to {}: {}",
path.display(), err);
}
}
}
@ -155,7 +155,7 @@ impl<'c, 'store, 'rstore> Helper<'c, 'store, 'rstore>
{
if decrypt(algo, &sk) {
if self.dump_session_key {
wprintln!("Session key: {}", hex::encode(&sk));
weprintln!("Session key: {}", hex::encode(&sk));
}
let id = self.key_identities.get(&KeyID::from(fpr)).cloned();
if let Some(ref id) = id {
@ -360,14 +360,14 @@ impl<'c, 'store, 'rstore> DecryptionHelper for Helper<'c, 'store, 'rstore>
}
Ok(Some(password)) => {
if let Err(_err) = key.unlock(password) {
wprintln!("Bad password.");
weprintln!("Bad password.");
continue;
}
}
Ok(None) => {
// Cancelled.
wprintln!("Skipping {}, {}",
keyid, userid);
weprintln!("Skipping {}, {}",
keyid, userid);
break;
}
}
@ -391,8 +391,8 @@ impl<'c, 'store, 'rstore> DecryptionHelper for Helper<'c, 'store, 'rstore>
}
}
Err(err) => {
wprintln!("Warning: unable to connect to keystore: {}",
err);
weprintln!("Warning: unable to connect to keystore: {}",
err);
}
}
@ -406,9 +406,9 @@ impl<'c, 'store, 'rstore> DecryptionHelper for Helper<'c, 'store, 'rstore>
Some(recipient)
}
});
wprintln!("No key to decrypt message. The message appears \
to be encrypted to:");
wprintln!();
weprintln!("No key to decrypt message. The message appears \
to be encrypted to:");
weprintln!();
for recipient in recipients.into_iter() {
let certs = self.sq.lookup(
std::iter::once(KeyHandle::from(recipient)),
@ -421,28 +421,28 @@ impl<'c, 'store, 'rstore> DecryptionHelper for Helper<'c, 'store, 'rstore>
match certs {
Ok(certs) => {
for cert in certs {
wprintln!(initial_indent = " - ",
"{}, {}",
cert.fingerprint(),
self.sq.best_userid(&cert, true));
weprintln!(initial_indent = " - ",
"{}, {}",
cert.fingerprint(),
self.sq.best_userid(&cert, true));
}
}
Err(err) => {
if let Some(StoreError::NotFound(_))
= err.downcast_ref()
{
wprintln!(initial_indent = " - ",
"{}, certificate not found",
recipient);
weprintln!(initial_indent = " - ",
"{}, certificate not found",
recipient);
} else {
wprintln!(initial_indent = " - ",
"{}, error looking up certificate: {}",
recipient, err);
weprintln!(initial_indent = " - ",
"{}, error looking up certificate: {}",
recipient, err);
}
}
};
}
wprintln!();
weprintln!();
return
Err(anyhow::anyhow!("No key to decrypt message"));
@ -456,7 +456,7 @@ impl<'c, 'store, 'rstore> DecryptionHelper for Helper<'c, 'store, 'rstore>
.and_then(|(algo, sk)| { if decrypt(algo, &sk) { Some(sk) } else { None }})
{
if self.dump_session_key {
wprintln!("Session key: {}", hex::encode(&sk));
weprintln!("Session key: {}", hex::encode(&sk));
}
return Ok(None);
}
@ -474,7 +474,7 @@ impl<'c, 'store, 'rstore> DecryptionHelper for Helper<'c, 'store, 'rstore>
.and_then(|(algo, sk)| { if decrypt(algo, &sk) { Some(sk) } else { None }})
{
if self.dump_session_key {
wprintln!("Session key: {}", hex::encode(&sk));
weprintln!("Session key: {}", hex::encode(&sk));
}
return Ok(None);
}
@ -485,11 +485,11 @@ impl<'c, 'store, 'rstore> DecryptionHelper for Helper<'c, 'store, 'rstore>
}
if first {
wprintln!("Incorrect password. \
Hint: enter empty password to cancel.");
weprintln!("Incorrect password. \
Hint: enter empty password to cancel.");
first = false;
} else {
wprintln!("Incorrect password.");
weprintln!("Incorrect password.");
}
}
}

View File

@ -181,9 +181,9 @@ pub fn dispatch(sq: Sq, c: download::Command)
let output_is_terminal
= output.path().is_none() && std::io::stdout().is_terminal();
if output_is_terminal {
wprintln!("Warning: will write the data to stdout, \
which appears to be a terminal. Use --output \
to write to a file instead.");
weprintln!("Warning: will write the data to stdout, \
which appears to be a terminal. Use --output \
to write to a file instead.");
}
}
@ -406,15 +406,15 @@ pub fn dispatch(sq: Sq, c: download::Command)
).is_ok();
if good {
wprintln!("Authenticated possible \
signer: {}, {}",
cert.fingerprint(),
sq.best_userid(&cert, true));
weprintln!("Authenticated possible \
signer: {}, {}",
cert.fingerprint(),
sq.best_userid(&cert, true));
} else {
wprintln!("Couldn't authenticate the \
alleged signer: {}, {}",
cert.fingerprint(),
sq.best_userid(&cert, true));
weprintln!("Couldn't authenticate the \
alleged signer: {}, {}",
cert.fingerprint(),
sq.best_userid(&cert, true));
}
if good {
@ -519,9 +519,9 @@ pub fn dispatch(sq: Sq, c: download::Command)
drop(progress_bar);
wprintln!();
wprintln!("Finished downloading data. Authenticating data.");
wprintln!();
weprintln!();
weprintln!("Finished downloading data. Authenticating data.");
weprintln!();
data_file.as_mut().rewind()?;
@ -536,9 +536,9 @@ pub fn dispatch(sq: Sq, c: download::Command)
if let Err(err) = result {
if let Some(path) = output.path() {
if let Err(err) = std::fs::remove_file(path) {
wprintln!("Verification failed, failed to remove \
unverified output saved to {}: {}",
path.display(), err);
weprintln!("Verification failed, failed to remove \
unverified output saved to {}: {}",
path.display(), err);
}
}

View File

@ -259,11 +259,11 @@ pub fn encrypt<'a, 'b: 'a>(
}
if ! bad.is_empty() {
wprintln!("Cannot encrypt to {}, {}:",
cert.fingerprint(),
sq.best_userid(&cert, true));
weprintln!("Cannot encrypt to {}, {}:",
cert.fingerprint(),
sq.best_userid(&cert, true));
for message in bad.into_iter() {
wprintln!(initial_indent=" - ", "{}", message);
weprintln!(initial_indent=" - ", "{}", message);
}
}
if ! use_expired_subkey && ! expired_keys.is_empty() {

View File

@ -65,10 +65,11 @@ pub fn dispatch(mut sq: Sq, c: inspect::Command)
if c.certs.is_empty() {
if let Some(path) = input.inner() {
if ! path.exists() &&
format!("{}", input).parse::<KeyHandle>().is_ok() {
wprintln!("The file {} does not exist, \
did you mean \"sq inspect --cert {}\"?",
input, input);
format!("{}", input).parse::<KeyHandle>().is_ok()
{
weprintln!("The file {} does not exist, \
did you mean \"sq inspect --cert {}\"?",
input, input);
}
}

View File

@ -43,8 +43,8 @@ fn list(sq: Sq, cmd: approvals::ListCommand) -> Result<()> {
continue;
}
wprintln!(initial_indent = " - ", "{}",
String::from_utf8_lossy(uid.value()));
weprintln!(initial_indent = " - ", "{}",
String::from_utf8_lossy(uid.value()));
let approved =
uid.attested_certifications().collect::<BTreeSet<_>>();
@ -108,45 +108,45 @@ fn list(sq: Sq, cmd: approvals::ListCommand) -> Result<()> {
}
}
wprintln!(initial_indent = " - ", "{}{}: {}",
issuer.as_ref()
.map(|c| format!("{} ", c.fingerprint()))
.unwrap_or_else(|| "".into()),
issuer.as_ref()
.and_then(|i| Some(sq.best_userid(i.to_cert().ok()?, true)
.to_string()))
.or(c.get_issuers().into_iter().next()
.map(|h| h.to_string()))
.unwrap_or_else(|| "no issuer information".into()),
if issuer.is_none() {
if let Some(e) = err {
e.to_string()
} else {
"issuer cert not found".into()
}
} else if approved {
"approved".into()
} else {
"unapproved".into()
});
weprintln!(initial_indent = " - ", "{}{}: {}",
issuer.as_ref()
.map(|c| format!("{} ", c.fingerprint()))
.unwrap_or_else(|| "".into()),
issuer.as_ref()
.and_then(|i| Some(sq.best_userid(i.to_cert().ok()?, true)
.to_string()))
.or(c.get_issuers().into_iter().next()
.map(|h| h.to_string()))
.unwrap_or_else(|| "no issuer information".into()),
if issuer.is_none() {
if let Some(e) = err {
e.to_string()
} else {
"issuer cert not found".into()
}
} else if approved {
"approved".into()
} else {
"unapproved".into()
});
any = true;
}
if ! any {
wprintln!(initial_indent = " - ", "no {} certifications",
if cmd.pending {
"unapproved"
} else {
"approved"
});
weprintln!(initial_indent = " - ", "no {} certifications",
if cmd.pending {
"unapproved"
} else {
"approved"
});
}
}
assert!(designated_userids.is_empty());
if ! cmd.pending && pending > 0 {
wprintln!("{} certifications are pending approval. Using `--pending` \
to see them.",
pending);
weprintln!("{} certifications are pending approval. Using `--pending` \
to see them.",
pending);
}
Ok(())
@ -192,8 +192,8 @@ fn update(
continue;
}
wprintln!(initial_indent = " - ", "{}",
String::from_utf8_lossy(uid.value()));
weprintln!(initial_indent = " - ", "{}",
String::from_utf8_lossy(uid.value()));
let previously_approved =
uid.attested_certifications().collect::<BTreeSet<_>>();
@ -362,40 +362,40 @@ fn update(
removed += 1;
}
wprintln!(initial_indent = " ", "{} {}{}: {}",
match (prev, next) {
(false, false) => '.',
(true, false) => '-',
(false, true) => '+',
(true, true) => '=',
},
issuer.as_ref()
.map(|c| format!("{} ", c.fingerprint()))
.unwrap_or_else(|| "".into()),
issuer.as_ref()
.and_then(|i| Some(sq.best_userid(i.to_cert().ok()?, true)
.to_string()))
.or(c.get_issuers().into_iter().next()
.map(|h| h.to_string()))
.unwrap_or_else(|| "no issuer information".into()),
if issuer.is_none() {
if let Some(e) = err {
e.to_string()
} else {
"issuer cert not found".into()
}
} else if next {
"approved".into()
} else if prev {
"previously approved".into()
} else {
"unapproved".into()
});
weprintln!(initial_indent = " ", "{} {}{}: {}",
match (prev, next) {
(false, false) => '.',
(true, false) => '-',
(false, true) => '+',
(true, true) => '=',
},
issuer.as_ref()
.map(|c| format!("{} ", c.fingerprint()))
.unwrap_or_else(|| "".into()),
issuer.as_ref()
.and_then(|i| Some(sq.best_userid(i.to_cert().ok()?, true)
.to_string()))
.or(c.get_issuers().into_iter().next()
.map(|h| h.to_string()))
.unwrap_or_else(|| "no issuer information".into()),
if issuer.is_none() {
if let Some(e) = err {
e.to_string()
} else {
"issuer cert not found".into()
}
} else if next {
"approved".into()
} else if prev {
"previously approved".into()
} else {
"unapproved".into()
});
any = true;
}
if ! any {
wprintln!(" no certifications");
weprintln!(" no certifications");
}
approval_signatures.append(&mut uid.attest_certifications2(
@ -409,19 +409,19 @@ fn update(
match (added, removed) {
(1, 1) => {
wprintln!("1 new approval, 1 approval retracted");
weprintln!("1 new approval, 1 approval retracted");
}
(added, 1) => {
wprintln!("{} new approvals, 1 approval retracted",
added);
weprintln!("{} new approvals, 1 approval retracted",
added);
}
(1, removed) => {
wprintln!("1 new approval, {} approvals retracted",
removed);
weprintln!("1 new approval, {} approvals retracted",
removed);
}
(added, removed) => {
wprintln!("{} new approvals, {} approvals retracted",
added, removed);
weprintln!("{} new approvals, {} approvals retracted",
added, removed);
}
}
@ -454,7 +454,7 @@ fn update(
} else {
let fipr = key.fingerprint();
if let Err(err) = sq.import_cert(key) {
wprintln!("Error importing updated cert: {}", err);
weprintln!("Error importing updated cert: {}", err);
return Err(err);
} else {
sq.hint(format_args!(

View File

@ -84,16 +84,16 @@ pub fn dispatch(sq: Sq, command: cli::key::delete::Command)
}
}
if ! bad.is_empty() {
wprintln!("Some keys are not valid according \
to the current policy:");
weprintln!("Some keys are not valid according \
to the current policy:");
for (fpr, err) in bad.into_iter() {
wprintln!(" - {}: {}",
fpr,
crate::one_line_error_chain(err));
weprintln!(" - {}: {}",
fpr,
crate::one_line_error_chain(err));
}
wprintln!("Cowardly refusing to delete all of the secret key \
material to avoid accidentally losing data. Use \
`sq key subkey delete` to delete the keys individually.");
weprintln!("Cowardly refusing to delete all of the secret key \
material to avoid accidentally losing data. Use \
`sq key subkey delete` to delete the keys individually.");
return Err(anyhow::anyhow!(
"The authenticity of some subkeys is uncertain."));
@ -120,20 +120,20 @@ pub fn dispatch(sq: Sq, command: cli::key::delete::Command)
{
if certs.len() > 1 {
die = true;
wprintln!("{} is associated with multiple certificates:",
ka.fingerprint());
weprintln!("{} is associated with multiple certificates:",
ka.fingerprint());
for cert in certs.iter() {
wprintln!(" - {}", cert.fingerprint());
weprintln!(" - {}", cert.fingerprint());
}
}
}
}
if die {
wprintln!("Cowardly refusing to delete secret key material to \
avoid accidentally losing data. Use \
`sq key subkey delete` to delete the keys \
individually.");
weprintln!("Cowardly refusing to delete secret key material to \
avoid accidentally losing data. Use \
`sq key subkey delete` to delete the keys \
individually.");
return Err(anyhow::anyhow!(
"Some keys are associated with multiple certificates."));

View File

@ -63,7 +63,7 @@ pub fn dispatch(sq: Sq, command: cli::key::export::Command)
if secret_keys.is_empty() {
for (fpr, err) in errs.into_iter() {
wprintln!("Exporting {}: {}", fpr, err);
weprintln!("Exporting {}: {}", fpr, err);
}
return Err(anyhow::anyhow!(
"Failed to export {}: no secret key material is available",

View File

@ -68,7 +68,7 @@ pub fn generate(
}
if command.userid.is_empty() {
wprintln!("No user ID given, using direct key signature");
weprintln!("No user ID given, using direct key signature");
} else {
// Make sure the user IDs are in canonical form. If not, and
// `--allow-non-canonical-userids` is not set, error out.
@ -339,9 +339,9 @@ pub fn generate(
&mut (Box::new(std::io::stderr()) as Box<dyn std::io::Write + Send + Sync>),
false, false)
{
wprintln!("Failed to display key: {}", err);
wprintln!("This is probably a bug in sq, please report it to \
https://gitlab.com/sequoia-pgp/sequoia-sq/-/issues/new .");
weprintln!("Failed to display key: {}", err);
weprintln!("This is probably a bug in sq, please report it to \
https://gitlab.com/sequoia-pgp/sequoia-sq/-/issues/new .");
}
}

View File

@ -39,7 +39,7 @@ fn import_internal(sq: &Sq, command: cli::key::import::Command,
let cert = match r {
Ok(cert) => cert,
Err(err) => {
wprintln!("Error reading {}: {}", file.display(), err);
weprintln!("Error reading {}: {}", file.display(), err);
if ret.is_ok() {
ret = Err(err);
}
@ -54,19 +54,18 @@ fn import_internal(sq: &Sq, command: cli::key::import::Command,
let cert_is_tsk = cert.is_tsk();
match sq.import_key(cert, stats) {
Ok((key, cert)) => {
wprintln!("Imported {} from {}: {}",
id, file.display(),
if key == cert {
key.to_string()
} else {
format!("key {}, cert {}", key, cert)
});
weprintln!("Imported {} from {}: {}",
id, file.display(),
if key == cert {
key.to_string()
} else {
format!("key {}, cert {}", key, cert)
});
}
Err(err) => {
wprintln!("Error importing {} from {}: {}",
id, file.display(), err);
weprintln!("Error importing {} from {}: {}",
id, file.display(), err);
if ! cert_is_tsk {
sq.hint(format_args!(

View File

@ -272,9 +272,9 @@ pub fn list(sq: Sq, mut cmd: cli::key::list::Command) -> Result<()> {
.sum::<usize>();
if hex >= 16 {
wprintln!("Warning: {} looks like a fingerprint or key ID, \
but its invalid. Treating it as a text pattern.",
pattern);
weprintln!("Warning: {} looks like a fingerprint or key ID, \
but its invalid. Treating it as a text pattern.",
pattern);
}
} else {
d = Some(cert_designator::CertDesignator::Cert(kh));
@ -305,16 +305,16 @@ pub fn list(sq: Sq, mut cmd: cli::key::list::Command) -> Result<()> {
for backend in &mut backends {
let devices = backend.list()?;
if devices.len() == 0 {
wprintln!(initial_indent = " - ", "Backend {} has no keys.",
backend.id()?);
weprintln!(initial_indent = " - ", "Backend {} has no keys.",
backend.id()?);
dirty = true;
}
for mut device in devices {
let keys = device.list()?;
if keys.len() == 0 {
wprintln!(initial_indent = " - ", "Device {}/{} has no keys.",
backend.id()?, device.id()?);
weprintln!(initial_indent = " - ", "Device {}/{} has no keys.",
backend.id()?, device.id()?);
dirty = true;
}
@ -410,13 +410,13 @@ pub fn list(sq: Sq, mut cmd: cli::key::list::Command) -> Result<()> {
}
if dirty {
wprintln!();
weprintln!();
}
dirty = true;
// Emit metadata.
wprintln!(initial_indent = " - ", "{}",
association.key().fingerprint());
weprintln!(initial_indent = " - ", "{}",
association.key().fingerprint());
// Show the user IDs that can be authenticated or are self signed.
if let Some(cert) = association.cert() {
@ -455,11 +455,11 @@ pub fn list(sq: Sq, mut cmd: cli::key::list::Command) -> Result<()> {
}
if userids.is_empty() {
wprintln!(initial_indent = " - ", "no user IDs");
weprintln!(initial_indent = " - ", "no user IDs");
} else {
let userid_count = userids.len();
if userid_count > 1 {
wprintln!(initial_indent = " - ", "user IDs:");
weprintln!(initial_indent = " - ", "user IDs:");
}
userids.sort_by(
@ -476,32 +476,32 @@ pub fn list(sq: Sq, mut cmd: cli::key::list::Command) -> Result<()> {
{
if amount > 0 || self_signed {
if userid_count == 1 {
wprintln!(initial_indent = " - ", "user ID: {}{}",
userid,
if revoked { " revoked" } else { "" });
weprintln!(initial_indent = " - ", "user ID: {}{}",
userid,
if revoked { " revoked" } else { "" });
} else {
wprintln!(initial_indent = " - ", "{}{}",
userid,
if revoked { " revoked" } else { "" });
weprintln!(initial_indent = " - ", "{}{}",
userid,
if revoked { " revoked" } else { "" });
}
}
}
}
}
wprintln!(initial_indent = " - ", "created {}",
association.key().creation_time().convert());
weprintln!(initial_indent = " - ", "created {}",
association.key().creation_time().convert());
if let Some(cert) = association.cert() {
for info in key_validity(&sq, cert, None).into_iter() {
wprintln!(initial_indent = " - ", "{}", info);
weprintln!(initial_indent = " - ", "{}", info);
}
}
// Primary key information, if any.
if let Some(primary) = keys.get(&association.key().fingerprint()) {
wprintln!(initial_indent = " - ", "usable {}", primary.usable_for());
weprintln!(initial_indent = " - ", "usable {}", primary.usable_for());
for loc in &primary.locations {
wprintln!(initial_indent = " - ", "{}", loc);
weprintln!(initial_indent = " - ", "{}", loc);
}
}
@ -511,22 +511,22 @@ pub fn list(sq: Sq, mut cmd: cli::key::list::Command) -> Result<()> {
.enumerate()
{
if i == 0 {
wprintln!();
weprintln!();
}
wprintln!(initial_indent = " - ", "{}", fp);
wprintln!(initial_indent = " - ", "created {}",
key.key.creation_time().convert());
weprintln!(initial_indent = " - ", "{}", fp);
weprintln!(initial_indent = " - ", "created {}",
key.key.creation_time().convert());
if let Some(cert) = association.cert() {
for info in key_validity(&sq, cert, Some(fp)).into_iter() {
wprintln!(initial_indent = " - ", "{}", info);
weprintln!(initial_indent = " - ", "{}", info);
}
}
wprintln!(initial_indent = " - ", "usable {}", key.usable_for());
weprintln!(initial_indent = " - ", "usable {}", key.usable_for());
for loc in &key.locations {
wprintln!(initial_indent = " - ", "{}", loc);
weprintln!(initial_indent = " - ", "{}", loc);
}
}
}

View File

@ -158,10 +158,10 @@ pub fn bind(sq: Sq, command: cli::key::subkey::bind::Command) -> Result<()>
Ok((cert, key, builder)) => Some((cert, key, builder)),
Err(err) => {
if ! missing {
wprintln!("Missing keys:");
weprintln!("Missing keys:");
}
wprintln!(initial_indent = " - ", "{}: {}", id, err);
weprintln!(initial_indent = " - ", "{}: {}", id, err);
missing = true;
None
@ -281,7 +281,7 @@ pub fn bind(sq: Sq, command: cli::key::subkey::bind::Command) -> Result<()>
}
if p == "".into() {
wprintln!("Giving up.");
weprintln!("Giving up.");
return Err(anyhow::anyhow!(
"Failed to unlock key: {}",
err.expect("must be set when we came here")));
@ -404,7 +404,7 @@ pub fn bind(sq: Sq, command: cli::key::subkey::bind::Command) -> Result<()>
sq.import_cert(cert).err()
};
if let Some(err) = result {
wprintln!("Error importing updated cert: {}", err);
weprintln!("Error importing updated cert: {}", err);
return Err(err);
} else {
sq.hint(format_args!(

View File

@ -66,7 +66,7 @@ pub fn dispatch(sq: Sq, command: crate::cli::key::subkey::export::Command)
if secret_keys.is_empty() {
for (fpr, err) in errs.into_iter() {
wprintln!("Exporting {}: {}", fpr, err);
weprintln!("Exporting {}: {}", fpr, err);
}
return Err(anyhow::anyhow!(
"Failed to export {}: no secret key material is available",

View File

@ -467,9 +467,9 @@ fn merge(sq: &Sq, inputs: Vec<PathBuf>, output: FileOrStdout,
}
if let Some((_sig, name, err)) = bad {
wprintln!("Could not add revocation certificate from {} \
to certificate: {}",
name, err);
weprintln!("Could not add revocation certificate from {} \
to certificate: {}",
name, err);
die = true;
} else {
missing.push((issuers[0].clone(), name.clone()));
@ -480,15 +480,15 @@ fn merge(sq: &Sq, inputs: Vec<PathBuf>, output: FileOrStdout,
match missing.as_slice() {
[] => (),
[(issuer, name)] => {
wprintln!("Couldn't merge revocation certificate \
from {}: missing {}.",
name, issuer);
weprintln!("Couldn't merge revocation certificate \
from {}: missing {}.",
name, issuer);
}
_ => {
wprintln!("Couldn't some merge revocation certificates:");
weprintln!("Couldn't some merge revocation certificates:");
for (issuer, name) in missing.into_iter() {
wprintln!(" - {}: missing {}",
name, issuer);
weprintln!(" - {}: missing {}",
name, issuer);
}
}
}

View File

@ -575,7 +575,7 @@ impl Method {
Some((cert, created)) => (cert, created),
None => {
if sq.verbose() {
wprintln!(
weprintln!(
"Not recording provenance information: \
{} is not known to be a verifying \
keyserver",
@ -608,7 +608,7 @@ impl Method {
Ok(None) => return None,
Err(err) => {
let print_err = || {
wprintln!(
weprintln!(
"Not recording provenance information: {}",
err);
};
@ -633,7 +633,7 @@ impl Method {
if sq.verbose() {
let invalid = "invalid data".to_string();
wprintln!(
weprintln!(
"Created the local CA {} for certifying \
certificates downloaded from this service. \
Use `sq pki link authorize --unconstrained --amount N {}` \
@ -765,7 +765,7 @@ impl Response {
if ! silent_errors || sq.verbose() || certs.is_empty() {
for (method, query, e) in errors {
pb.suspend(|| wprintln!("{}: {}: {}", method, query, e));
pb.suspend(|| weprintln!("{}: {}: {}", method, query, e));
}
}
@ -1167,7 +1167,7 @@ pub fn dispatch_keyserver(
// an error, and only print the message in
// verbose mode.
if sq.verbose() {
wprintln!("{}: {}", url, e);
weprintln!("{}: {}", url, e);
}
},
Err(e) => {
@ -1187,7 +1187,7 @@ pub fn dispatch_keyserver(
encryption-capable."));
}
wprintln!("{}: {}", url, e);
weprintln!("{}: {}", url, e);
if result.is_ok() {
result = Err((url, e));
}

View File

@ -57,10 +57,10 @@ pub fn dispatch(sq: Sq, command: Command)
if let Some(path) = command.input.inner() {
if ! path.exists() &&
format!("{}", command.input).parse::<KeyHandle>().is_ok() {
wprintln!("The file {} does not exist, \
did you mean \"sq packet dump \
--cert {}\"?",
path.display(), path.display());
weprintln!("The file {} does not exist, \
did you mean \"sq packet dump \
--cert-file {}\"?",
path.display(), path.display());
}
}

View File

@ -203,19 +203,19 @@ pub fn list(sq: Sq, c: link::ListCommand)
}
if dirty {
wprintln!();
weprintln!();
}
dirty = true;
wprintln!(initial_indent=" - ┌ ", subsequent_indent="",
"{}", cert.fingerprint());
wprintln!(initial_indent="",
"{:?}", String::from_utf8_lossy(userid.value()));
weprintln!(initial_indent=" - ┌ ", subsequent_indent="",
"{}", cert.fingerprint());
weprintln!(initial_indent="",
"{:?}", String::from_utf8_lossy(userid.value()));
const INDENT: &'static str = " - ";
if amount == 0 {
wprintln!(initial_indent=INDENT, "link was retracted");
weprintln!(initial_indent=INDENT, "link was retracted");
} else {
let mut regex: Vec<_> = certification.regular_expressions()
.map(|re| String::from_utf8_lossy(re))
@ -234,28 +234,28 @@ pub fn list(sq: Sq, c: link::ListCommand)
} else {
"is linked"
};
wprintln!(initial_indent=INDENT, "{}", summary);
weprintln!(initial_indent=INDENT, "{}", summary);
if let Some(e) = certification.signature_expiration_time() {
wprintln!(initial_indent=INDENT,
"expiration: {}",
chrono::DateTime::<chrono::Utc>::from(e)
.format("%Y%m%d"));
weprintln!(initial_indent=INDENT,
"expiration: {}",
chrono::DateTime::<chrono::Utc>::from(e)
.format("%Y%m%d"));
}
if depth != 0 && depth != 255 {
wprintln!(initial_indent=INDENT,
"trust depth: {}", depth);
weprintln!(initial_indent=INDENT,
"trust depth: {}", depth);
}
if amount != sequoia_wot::FULLY_TRUSTED as u8 {
wprintln!(initial_indent=INDENT,
"trust amount: {}", amount);
weprintln!(initial_indent=INDENT,
"trust amount: {}", amount);
}
if ! regex.is_empty() {
wprintln!(initial_indent=INDENT,
"regular expressions: {}", regex.join("; "));
weprintln!(initial_indent=INDENT,
"regular expressions: {}", regex.join("; "));
}
}
}

View File

@ -44,9 +44,9 @@ pub fn dispatch(sq: Sq, command: cli::verify::Command)
if result.is_err() {
if let Some(path) = command.output.path() {
if let Err(err) = std::fs::remove_file(path) {
wprintln!("Verification failed, failed to remove \
unverified output saved to {}: {}",
path.display(), err);
weprintln!("Verification failed, failed to remove \
unverified output saved to {}: {}",
path.display(), err);
}
}
}
@ -177,7 +177,7 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> {
p(&mut status, "bad key", 1, self.broken_keys);
p(&mut status, "broken signatures", 1, self.broken_signatures);
if ! status.is_empty() {
wprintln!("{}.", status);
weprintln!("{}.", status);
}
}
@ -193,7 +193,7 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> {
let (sig, ka) = match result {
Ok(GoodChecksum { sig, ka, .. }) => (sig, ka),
Err(MalformedSignature { error, .. }) => {
wprintln!("Malformed signature:");
weprintln!("Malformed signature:");
print_error_chain(error);
self.broken_signatures += 1;
continue;
@ -206,9 +206,9 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> {
0 => "signature".into(),
n => format!("level {} notarization", n),
};
wprintln!("Can't authenticate {} allegedly made by {}: \
missing certificate.",
what, issuer);
weprintln!("Can't authenticate {} allegedly made by {}: \
missing certificate.",
what, issuer);
self.sq.hint(format_args!(
"Consider searching for the certificate using:"))
@ -220,15 +220,15 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> {
continue;
},
Err(UnboundKey { cert, error, .. }) => {
wprintln!("Signing key on {} is not bound:",
cert.fingerprint());
weprintln!("Signing key on {} is not bound:",
cert.fingerprint());
print_error_chain(error);
self.broken_keys += 1;
continue;
},
Err(BadKey { ka, error, .. }) => {
wprintln!("Signing key on {} is bad:",
ka.cert().fingerprint());
weprintln!("Signing key on {} is bad:",
ka.cert().fingerprint());
print_error_chain(error);
self.broken_keys += 1;
continue;
@ -239,8 +239,8 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> {
0 => "signature".into(),
n => format!("level {} notarizing signature", n),
};
wprintln!("Error verifying {} made by {}:",
what, issuer);
weprintln!("Error verifying {} made by {}:",
what, issuer);
print_error_chain(error);
self.bad_signatures += 1;
continue;
@ -274,10 +274,10 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> {
cert_store.certified_userids_of(&cert_fpr);
if userids.is_empty() {
wprintln!(indent=prefix,
"{} cannot be authenticated. \
It has no User IDs",
cert_fpr);
weprintln!(indent=prefix,
"{} cannot be authenticated. \
It has no User IDs",
cert_fpr);
} else {
let n = sequoia_wot::NetworkBuilder::rooted(
&cert_store, &*trust_roots).build();
@ -294,29 +294,29 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> {
let amount = paths.amount();
let authenticated = if amount >= sequoia_wot::FULLY_TRUSTED {
wprintln!(indent=prefix,
"Fully authenticated \
({} of {}) {}, {}",
amount,
sequoia_wot::FULLY_TRUSTED,
cert_fpr,
userid_str);
weprintln!(indent=prefix,
"Fully authenticated \
({} of {}) {}, {}",
amount,
sequoia_wot::FULLY_TRUSTED,
cert_fpr,
userid_str);
true
} else if amount > 0 {
wprintln!(indent=prefix,
"Partially authenticated \
({} of {}) {}, {:?} ",
amount,
sequoia_wot::FULLY_TRUSTED,
cert_fpr,
userid_str);
weprintln!(indent=prefix,
"Partially authenticated \
({} of {}) {}, {:?} ",
amount,
sequoia_wot::FULLY_TRUSTED,
cert_fpr,
userid_str);
false
} else {
wprintln!(indent=prefix,
"{}: {:?} is unauthenticated \
and may be an impersonation!",
cert_fpr,
userid_str);
weprintln!(indent=prefix,
"{}: {:?} is unauthenticated \
and may be an impersonation!",
cert_fpr,
userid_str);
false
};
@ -380,21 +380,21 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> {
let level = sig.level();
match (level == 0, authenticated) {
(true, true) => {
wprintln!(indent=prefix,
"Authenticated signature made by {} ({:?})",
label, signer_userid);
weprintln!(indent=prefix,
"Authenticated signature made by {} ({:?})",
label, signer_userid);
}
(false, true) => {
wprintln!(indent=prefix,
"Authenticated level {} notarization \
made by {} ({:?})",
level, label, signer_userid);
weprintln!(indent=prefix,
"Authenticated level {} notarization \
made by {} ({:?})",
level, label, signer_userid);
}
(true, false) => {
wprintln!(indent=prefix,
"Can't authenticate signature made by {} ({:?}): \
the certificate can't be authenticated.",
label, signer_userid);
weprintln!(indent=prefix,
"Can't authenticate signature made by {} ({:?}): \
the certificate can't be authenticated.",
label, signer_userid);
self.sq.hint(format_args!(
"After checking that {} belongs to {:?}, \
@ -406,11 +406,11 @@ impl<'c, 'store, 'rstore> VHelper<'c, 'store, 'rstore> {
.done();
}
(false, false) => {
wprintln!(indent=prefix,
"Can't authenticate level {} notarization \
made by {} ({:?}): the certificate \
can't be authenticated.",
level, label, signer_userid);
weprintln!(indent=prefix,
"Can't authenticate level {} notarization \
made by {} ({:?}): the certificate \
can't be authenticated.",
level, label, signer_userid);
self.sq.hint(format_args!(
"After checking that {} belongs to {:?}, \

View File

@ -9,10 +9,10 @@ use crate::{
pub fn dispatch(_sq: Sq, _c: version::Command)
-> Result<()>
{
wprintln!("sq {}", env!("CARGO_PKG_VERSION"));
wprintln!("using sequoia-openpgp {}", sequoia_openpgp::VERSION);
wprintln!("with cryptographic backend {}",
sequoia_openpgp::crypto::backend());
weprintln!("sq {}", env!("CARGO_PKG_VERSION"));
weprintln!("using sequoia-openpgp {}", sequoia_openpgp::VERSION);
weprintln!("with cryptographic backend {}",
sequoia_openpgp::crypto::backend());
Ok(())
}

View File

@ -57,8 +57,8 @@ where
for ka in kas.into_iter() {
let no_secret_key_material = ! ka.has_secret();
if no_secret_key_material {
wprintln!("{}{} does not contain any secret key material",
warning, ka.fingerprint());
weprintln!("{}{} does not contain any secret key material",
warning, ka.fingerprint());
no_secret_key_material_count += 1;
continue;
}
@ -75,8 +75,8 @@ where
let no_secret_key_material = remote_keys.is_empty();
if no_secret_key_material {
wprintln!("{}{} does not contain any secret key material",
warning, ka.fingerprint());
weprintln!("{}{} does not contain any secret key material",
warning, ka.fingerprint());
no_secret_key_material_count += 1;
continue;
}

View File

@ -241,7 +241,7 @@ where P: cert_designator::ArgumentPrefix,
let fipr = cert.fingerprint();
if let Err(err) = cert_store.update(Arc::new(cert.into())) {
wprintln!("Error importing updated cert: {}", err);
weprintln!("Error importing updated cert: {}", err);
return Err(err);
} else {
sq.hint(format_args!(

View File

@ -83,7 +83,7 @@ where
if ! unlocked {
if let Some(hint) = hint {
wprintln!("{}", hint);
weprintln!("{}", hint);
}
let time = key.creation_time().convert().to_string();
@ -125,7 +125,7 @@ where
break;
}
Err(err) => {
wprintln!("Failed to unlock key: {}", err);
weprintln!("Failed to unlock key: {}", err);
}
}
}

View File

@ -86,16 +86,16 @@ fn prompt_for_new_internal(
let password = prompt_password(sq, &p0)?;
if password.is_empty() && ! allow_none {
wprintln!("Password required. Please try again.");
wprintln!();
weprintln!("Password required. Please try again.");
weprintln!();
continue;
}
let password_repeat = prompt_password(sq, &p1)?;
if password != password_repeat {
wprintln!("The passwords do not match. Please try again.");
wprintln!();
weprintln!("The passwords do not match. Please try again.");
weprintln!();
continue;
}

View File

@ -271,15 +271,15 @@ pub fn authenticate<'store, 'rstore>(
// Check if the certificate has expired.
if let Err(err) = vc.alive() {
wprintln!("Warning: {} is not live: {}.",
cert.fingerprint(), err);
weprintln!("Warning: {} is not live: {}.",
cert.fingerprint(), err);
}
}
Err(err) => {
wprintln!("Warning: {} is not valid according to \
the current policy: {}.",
cert.fingerprint(),
crate::one_line_error_chain(err));
weprintln!("Warning: {} is not valid according to \
the current policy: {}.",
cert.fingerprint(),
crate::one_line_error_chain(err));
}
};
@ -290,27 +290,27 @@ pub fn authenticate<'store, 'rstore>(
if let Some((reason, message))
= sigs[0].reason_for_revocation()
{
wprintln!("Warning: {} is revoked: {}{}",
cert.fingerprint(),
reason,
if message.is_empty() {
"".to_string()
} else {
format!(": {:?}",
String::from_utf8_lossy(message))
});
weprintln!("Warning: {} is revoked: {}{}",
cert.fingerprint(),
reason,
if message.is_empty() {
"".to_string()
} else {
format!(": {:?}",
String::from_utf8_lossy(message))
});
} else {
wprintln!("Warning: {} is revoked: unspecified reason",
cert.fingerprint());
weprintln!("Warning: {} is revoked: unspecified reason",
cert.fingerprint());
}
}
// See if there is a matching self-signed User ID.
if let Some(userid) = userid {
if ! have_self_signed_userid(cert, &UserID::from(userid), email) {
wprintln!("Warning: {} is not a \
self-signed User ID for {}.",
userid, cert.fingerprint());
weprintln!("Warning: {} is not a \
self-signed User ID for {}.",
userid, cert.fingerprint());
}
}
@ -324,8 +324,8 @@ pub fn authenticate<'store, 'rstore>(
})
})
{
wprintln!("Warning: {} has no valid certifications.",
cert.fingerprint());
weprintln!("Warning: {} has no valid certifications.",
cert.fingerprint());
}
}
}
@ -338,10 +338,10 @@ pub fn authenticate<'store, 'rstore>(
let userid_check = UserID::from(format!("<{}>", email));
if let Ok(Some(email_check)) = userid_check.email2() {
if userid == email_check {
wprintln!("WARNING: {} appears to be a bare \
email address. Perhaps you forgot \
to specify --email.",
email);
weprintln!("WARNING: {} appears to be a bare \
email address. Perhaps you forgot \
to specify --email.",
email);
}
}
}
@ -352,15 +352,15 @@ pub fn authenticate<'store, 'rstore>(
if n.roots().iter().all(|r| {
let fpr = r.fingerprint();
if let Err(err) = n.lookup_synopsis_by_fpr(&fpr) {
wprintln!("Looking up trust root ({}): {}.",
fpr, err);
weprintln!("Looking up trust root ({}): {}.",
fpr, err);
true
} else {
false
}
})
{
wprintln!("No trust roots found.");
weprintln!("No trust roots found.");
}
}
}
@ -377,17 +377,17 @@ pub fn authenticate<'store, 'rstore>(
// We are in gossip mode. Mention `sq pki link` as a way to
// mark bindings as authenticated.
if ! bindings.is_empty() {
wprintln!("After checking that a user ID really belongs to \
a certificate, use `sq pki link add` to mark \
the binding as authenticated, or use \
`sq network fetch FINGERPRINT|EMAIL` to look for \
new certifications.");
weprintln!("After checking that a user ID really belongs to \
a certificate, use `sq pki link add` to mark \
the binding as authenticated, or use \
`sq network fetch FINGERPRINT|EMAIL` to look for \
new certifications.");
}
} else if bindings.is_empty() {
// There are no matching bindings. Tell the user about `sq
// network fetch`.
if let Some(pattern) = pattern() {
wprintln!("No bindings match.");
weprintln!("No bindings match.");
sq.hint(format_args!(
"Try searching public directories:"))
@ -395,8 +395,8 @@ pub fn authenticate<'store, 'rstore>(
.arg(pattern)
.done();
} else {
wprintln!("The certificate store does not contain any \
certificates.");
weprintln!("The certificate store does not contain any \
certificates.");
sq.hint(format_args!(
"Consider creating a key for yourself:"))
@ -426,18 +426,18 @@ pub fn authenticate<'store, 'rstore>(
let bindings_not_shown = bindings - bindings_shown;
if bindings == 1 {
wprintln!("1 binding found.");
weprintln!("1 binding found.");
} else {
wprintln!("{} bindings found.", bindings);
weprintln!("{} bindings found.", bindings);
}
if bindings_not_shown == 1 {
wprintln!("Skipped 1 binding, which could not be authenticated.");
wprintln!("Pass `--gossip` to see the unauthenticated binding.");
weprintln!("Skipped 1 binding, which could not be authenticated.");
weprintln!("Pass `--gossip` to see the unauthenticated binding.");
} else {
wprintln!("Skipped {} bindings, which could not be authenticated.",
weprintln!("Skipped {} bindings, which could not be authenticated.",
bindings_not_shown);
wprintln!("Pass `--gossip` to see the unauthenticated bindings.");
weprintln!("Pass `--gossip` to see the unauthenticated bindings.");
}
}

View File

@ -462,7 +462,7 @@ The certifier is the same as the certificate to certify."));
let fipr = cert.fingerprint();
if let Err(err) = cert_store.update(Arc::new(cert.into())) {
wprintln!("Error importing updated cert: {}", err);
weprintln!("Error importing updated cert: {}", err);
return Err(err);
} else if ! local {
sq.hint(format_args!(

View File

@ -33,7 +33,7 @@ use super::OutputType;
/// Prints a Path Error
pub fn print_path_error(err: Error) {
wprintln!(initial_indent = "", "Checking path: {}", err);
weprintln!(initial_indent = "", "Checking path: {}", err);
}
/// Prints information of a Path for a target UserID associated with a KeyHandle
@ -43,7 +43,7 @@ pub fn print_path_header(
amount: usize,
required_amount: usize,
) {
wprintln!(
weprintln!(
initial_indent="",
subsequent_indent=" ",
"[{}] {} {}: {} authenticated ({}%)",
@ -74,25 +74,25 @@ pub fn print_path(path: &PathLints, target_userid: &UserID, prefix: &str)
-> Result<()>
{
let certification_count = path.certifications().count();
wprintln!(initial_indent=format!("{}◯─┬ ", prefix),
subsequent_indent=format!("{}│ │ ", prefix),
"{}", path.root().key_handle());
wprintln!(initial_indent=format!("{}│ └ ", prefix),
subsequent_indent=format!("{}", prefix),
"{}",
if certification_count == 0 {
format!("{:?}", String::from_utf8_lossy(target_userid.value()))
} else if let Some(userid) = path.root().primary_userid() {
format!("({:?})", String::from_utf8_lossy(userid.value()))
} else {
format!("")
});
weprintln!(initial_indent=format!("{}◯─┬ ", prefix),
subsequent_indent=format!("{}│ │ ", prefix),
"{}", path.root().key_handle());
weprintln!(initial_indent=format!("{}│ └ ", prefix),
subsequent_indent=format!("{}", prefix),
"{}",
if certification_count == 0 {
format!("{:?}", String::from_utf8_lossy(target_userid.value()))
} else if let Some(userid) = path.root().primary_userid() {
format!("({:?})", String::from_utf8_lossy(userid.value()))
} else {
format!("")
});
if path.certifications().count() == 0 {
wprintln!(indent=prefix, "");
wprintln!(initial_indent=format!("{}└── ", prefix),
subsequent_indent=format!("{} ", prefix),
"Self-signed user ID.");
weprintln!(indent=prefix, "");
weprintln!(initial_indent=format!("{}└── ", prefix),
subsequent_indent=format!("{} ", prefix),
"Self-signed user ID.");
return Ok(());
}
@ -157,13 +157,13 @@ pub fn print_path(path: &PathLints, target_userid: &UserID, prefix: &str)
write!(&mut line, " No adequate certification found.")?;
}
wprintln!(indent=prefix, "");
wprintln!(indent=format!("{}", prefix), "{}", line);
wprintln!(indent=prefix, "");
weprintln!(indent=prefix, "");
weprintln!(indent=format!("{}", prefix), "{}", line);
weprintln!(indent=prefix, "");
for err in cert.errors().iter().chain(cert.lints()) {
for (i, msg) in error_chain(err).into_iter().enumerate() {
wprintln!(
weprintln!(
indent=format!(
"{}│ {}", prefix, if i == 0 { "" } else { " " }),
"{}", msg);
@ -171,38 +171,38 @@ pub fn print_path(path: &PathLints, target_userid: &UserID, prefix: &str)
}
for err in certification.errors().iter().chain(certification.lints()) {
for (i, msg) in error_chain(err).into_iter().enumerate() {
wprintln!(
weprintln!(
indent=format!(
"{}│ {}", prefix, if i == 0 { "" } else { " " }),
"{}", msg);
}
}
wprintln!(initial_indent=format!("{}{}─┬ ", prefix,
if last { "" } else { "" }),
subsequent_indent=format!("{}{}", prefix,
if last { " " } else { "" }),
"{}", certification.target());
wprintln!(initial_indent=format!("{}{}", prefix,
if last { " " } else { "" }),
subsequent_indent=format!("{}{} ", prefix,
if last { " " } else { "" }),
"{}",
if last {
format!("{:?}", String::from_utf8_lossy(target_userid.value()))
} else if let Some(userid) =
certification.target_cert().and_then(|c| c.primary_userid())
{
format!("({:?})", String::from_utf8_lossy(userid.value()))
} else {
"".into()
});
weprintln!(initial_indent=format!("{}{}─┬ ", prefix,
if last { "" } else { "" }),
subsequent_indent=format!("{}{}", prefix,
if last { " " } else { "" }),
"{}", certification.target());
weprintln!(initial_indent=format!("{}{}", prefix,
if last { " " } else { "" }),
subsequent_indent=format!("{}{} ", prefix,
if last { " " } else { "" }),
"{}",
if last {
format!("{:?}", String::from_utf8_lossy(target_userid.value()))
} else if let Some(userid) =
certification.target_cert().and_then(|c| c.primary_userid())
{
format!("({:?})", String::from_utf8_lossy(userid.value()))
} else {
"".into()
});
if last {
let target = path.certs().last().expect("have one");
for err in target.errors().iter().chain(target.lints()) {
for (i, msg) in error_chain(err).into_iter().enumerate() {
wprintln!(
weprintln!(
indent=format!(
"{}│ {}", prefix, if i == 0 { "" } else { " " }),
"{}", msg);
@ -211,7 +211,7 @@ pub fn print_path(path: &PathLints, target_userid: &UserID, prefix: &str)
}
}
wprintln!("");
weprintln!("");
Ok(())
}
@ -341,20 +341,20 @@ impl OutputType for ConciseHumanReadableOutputNetwork<'_, '_, '_> {
}
if ! first_shown {
wprintln!();
weprintln!();
}
wprintln!(initial_indent = " - ", "{}", fingerprint);
weprintln!(initial_indent = " - ", "{}", fingerprint);
if cert.primary_key().key().creation_time() != ca_creation_time() {
wprintln!(initial_indent = " - ", "created {}",
cert.primary_key().key().creation_time().convert());
weprintln!(initial_indent = " - ", "created {}",
cert.primary_key().key().creation_time().convert());
}
for info in extra_info.into_iter() {
wprintln!(initial_indent = " - ", "{}", info);
weprintln!(initial_indent = " - ", "{}", info);
}
wprintln!();
weprintln!();
}
let revoked = if let Some(Ok(ref vc)) = vc {
@ -375,22 +375,22 @@ impl OutputType for ConciseHumanReadableOutputNetwork<'_, '_, '_> {
None
};
wprintln!(initial_indent = " - ", "[ {} ] {}",
if revoked.is_some() {
"revoked".to_string()
} else if aggregated_amount >= self.required_amount {
"".to_string()
} else {
format!("{:3}/120", aggregated_amount)
},
String::from_utf8_lossy(userid.value()));
weprintln!(initial_indent = " - ", "[ {} ] {}",
if revoked.is_some() {
"revoked".to_string()
} else if aggregated_amount >= self.required_amount {
"".to_string()
} else {
format!("{:3}/120", aggregated_amount)
},
String::from_utf8_lossy(userid.value()));
if self.paths {
wprintln!();
weprintln!();
for (i, (path, amount)) in paths.iter().enumerate() {
if paths.len() > 1 {
wprintln!(
weprintln!(
initial_indent=" ",
"Path #{}{}of{}{}, trust amount {}:",
i + 1, NBSP, NBSP,

View File

@ -121,8 +121,8 @@ where
}
userids.push(designator.resolve_to(userid));
} else {
wprintln!("{:?} is not a self-signed user ID.",
String::from_utf8_lossy(userid.value()));
weprintln!("{:?} is not a self-signed user ID.",
String::from_utf8_lossy(userid.value()));
missing = true;
}
}
@ -134,8 +134,8 @@ where
let userid = match UserID::from_address(None, None, email) {
Ok(userid) => userid,
Err(err) => {
wprintln!("{:?} is not a valid email address: {}",
email, err);
weprintln!("{:?} is not a valid email address: {}",
email, err);
bad = Some(err);
continue;
}
@ -146,14 +146,14 @@ where
let email_normalized = match userid.email_normalized() {
Ok(Some(email)) => email,
Ok(None) => {
wprintln!("{:?} is not a valid email address", email);
weprintln!("{:?} is not a valid email address", email);
bad = Some(anyhow::anyhow!(format!(
"{:?} is not a valid email address", email)));
continue;
}
Err(err) => {
wprintln!("{:?} is not a valid email address: {}",
email, err);
weprintln!("{:?} is not a valid email address: {}",
email, err);
bad = Some(err);
continue;
}
@ -166,9 +166,9 @@ where
== ua.email_normalized().unwrap_or(None).as_ref()
{
if found {
wprintln!("{} is ambiguous: it matches \
multiple self-signed user IDs.",
email);
weprintln!("{} is ambiguous: it matches \
multiple self-signed user IDs.",
email);
ambiguous_email = true;
}
@ -203,7 +203,7 @@ where
if userid.name2().ok() != Some(Some(&name[..])) {
let err = format!("{:?} is not a valid display name",
name);
wprintln!("{}", err);
weprintln!("{}", err);
bad = Some(anyhow::anyhow!(err));
continue;
};
@ -213,9 +213,9 @@ where
if let Ok(Some(n)) = ua.userid().name2() {
if n == name {
if found {
wprintln!("{:?} is ambiguous: it matches \
multiple self-signed user IDs.",
name);
weprintln!("{:?} is ambiguous: it matches \
multiple self-signed user IDs.",
name);
ambiguous_name = true;
}
@ -247,23 +247,23 @@ where
}
if missing || ambiguous_email || ambiguous_name {
wprintln!("{}'s self-signed user IDs:", vc.fingerprint());
weprintln!("{}'s self-signed user IDs:", vc.fingerprint());
let mut have_valid = false;
for ua in vc.userids() {
if let Ok(u) = std::str::from_utf8(ua.userid().value()) {
have_valid = true;
wprintln!(initial_indent=" - ",
subsequent_indent=" ",
"{:?}", u);
weprintln!(initial_indent=" - ",
subsequent_indent=" ",
"{:?}", u);
}
}
if ! have_valid {
wprintln!(" - Certificate has no valid self-signed user IDs.");
weprintln!(" - Certificate has no valid self-signed user IDs.");
}
if let Ok(null) = vc.clone().with_policy(&NULL_POLICY, vc.time()) {
if vc.userids().count() < null.userids().count() {
wprintln!("Invalid self-signed user IDs:");
weprintln!("Invalid self-signed user IDs:");
let valid: BTreeSet<_>
= vc.userids().map(|ua| ua.userid().clone()).collect();
for ua in null.userids() {
@ -273,9 +273,9 @@ where
if let Ok(u) = std::str::from_utf8(ua.userid().value()) {
if let Err(err) = ua.with_policy(vc.policy(), vc.time()) {
wprintln!(initial_indent=" - ",
subsequent_indent=" ",
"{:?}: {}", u, err);
weprintln!(initial_indent=" - ",
subsequent_indent=" ",
"{:?}: {}", u, err);
}
}
}
@ -285,22 +285,22 @@ where
if missing {
if add_userid_arg && add_email_arg {
wprintln!("Use `--userid-or-add` or `--email-or-add` to use \
a user ID even if it isn't self signed, or has \
an invalid self signature.");
weprintln!("Use `--userid-or-add` or `--email-or-add` to use \
a user ID even if it isn't self signed, or has \
an invalid self signature.");
}
return Err(anyhow::anyhow!("No matching self-signed user ID"));
}
if ambiguous_email {
wprintln!("Use `--userid` with the full user ID, or \
`--userid-or-add` to add a new user ID.");
weprintln!("Use `--userid` with the full user ID, or \
`--userid-or-add` to add a new user ID.");
return Err(anyhow::anyhow!("\
An email address does not unambiguously designate a \
self-signed user ID"));
}
if ambiguous_name {
wprintln!("Use `--userid` with the full user ID, or \
`--userid-or-add` to add a new user ID.");
weprintln!("Use `--userid` with the full user ID, or \
`--userid-or-add` to add a new user ID.");
return Err(anyhow::anyhow!("\
A name does not unambiguously designate a \
self-signed user ID"));

View File

@ -140,15 +140,15 @@ pub(crate) fn lint_userids(uids: &[UserID]) -> Result<(), anyhow::Error> {
Ok(())
} else {
if non_canonical.len() == 1 {
wprintln!("{}.", non_canonical[0]);
wprintln!();
weprintln!("{}.", non_canonical[0]);
weprintln!();
} else {
wprintln!("The following user IDs are not in canonical form:");
wprintln!();
weprintln!("The following user IDs are not in canonical form:");
weprintln!();
for err in non_canonical.iter() {
wprintln!(initial_indent = " - ", "{}", err);
weprintln!(initial_indent = " - ", "{}", err);
}
wprintln!();
weprintln!();
}
let bare_email = non_canonical.iter()
@ -161,18 +161,18 @@ pub(crate) fn lint_userids(uids: &[UserID]) -> Result<(), anyhow::Error> {
})
.next();
wprintln!("Canonical user IDs are of the form \
`Name <localpart@example.org>`. {}\
Consider fixing the user IDs or passing \
`--allow-non-canonical-userids`.",
if let Some(uid) = bare_email {
format!("Bare email addresses should be wrapped in angle \
brackets like so `<{}>`. ",
String::from_utf8_lossy(uid.value()))
} else {
"".to_string()
});
wprintln!();
weprintln!("Canonical user IDs are of the form \
`Name <localpart@example.org>`. {}\
Consider fixing the user IDs or passing \
`--allow-non-canonical-userids`.",
if let Some(uid) = bare_email {
format!("Bare email addresses should be wrapped in angle \
brackets like so `<{}>`. ",
String::from_utf8_lossy(uid.value()))
} else {
"".to_string()
});
weprintln!();
Err(anyhow::anyhow!("\
Some user IDs are not in canonical form"))
@ -223,15 +223,15 @@ pub fn lint_names(names: &[String]) -> Result<(), anyhow::Error> {
Ok(())
} else {
if non_canonical.len() == 1 {
wprintln!("{}.", non_canonical[0]);
wprintln!();
weprintln!("{}.", non_canonical[0]);
weprintln!();
} else {
wprintln!("The following names have issues:");
wprintln!();
weprintln!("The following names have issues:");
weprintln!();
for err in non_canonical.iter() {
wprintln!(initial_indent = " - ", "{}", err);
weprintln!(initial_indent = " - ", "{}", err);
}
wprintln!();
weprintln!();
}
Err(anyhow::anyhow!("Some names had issues"))
@ -282,15 +282,15 @@ pub fn lint_emails(emails: &[String]) -> Result<(), anyhow::Error> {
Ok(())
} else {
if non_canonical.len() == 1 {
wprintln!("{}.", non_canonical[0]);
wprintln!();
weprintln!("{}.", non_canonical[0]);
weprintln!();
} else {
wprintln!("The following email addresses have issues:");
wprintln!();
weprintln!("The following email addresses have issues:");
weprintln!();
for err in non_canonical.iter() {
wprintln!(initial_indent = " - ", "{}", err);
weprintln!(initial_indent = " - ", "{}", err);
}
wprintln!();
weprintln!();
}
Err(anyhow::anyhow!("Some email addresses had issues"))

View File

@ -14,15 +14,15 @@ macro_rules! platform {
}
/// Like eprintln, but nicely wraps lines.
macro_rules! wprintln {
macro_rules! weprintln {
{} => {
eprintln!();
};
{ indent=$i: expr, $($arg: expr),* } => {{
let i = $i;
crate::output::wrapping::iwprintln(i.as_ref(), i.as_ref(),
format_args!($($arg),*))
crate::output::wrapping::iweprintln(i.as_ref(), i.as_ref(),
format_args!($($arg),*))
}};
{
@ -32,8 +32,8 @@ macro_rules! wprintln {
} => {{
let ii = $ii;
let si = $si;
crate::output::wrapping::iwprintln(ii.as_ref(), si.as_ref(),
format_args!($($arg),*))
crate::output::wrapping::iweprintln(ii.as_ref(), si.as_ref(),
format_args!($($arg),*))
}};
{
@ -42,16 +42,16 @@ macro_rules! wprintln {
} => {{
let ii = $ii;
let si = format!("{:1$}", "", ii.len());
crate::output::wrapping::iwprintln(ii.as_ref(), si.as_ref(),
format_args!($($arg),*))
crate::output::wrapping::iweprintln(ii.as_ref(), si.as_ref(),
format_args!($($arg),*))
}};
{ $($arg: expr),* } => {
crate::output::wrapping::wprintln(format_args!($($arg),*))
crate::output::wrapping::weprintln(format_args!($($arg),*))
};
}
/// Like wprintln, but doesn't emit anything in quiet mode.
/// Like weprintln, but doesn't emit anything in quiet mode.
macro_rules! make_qprintln {
($quiet: expr) => {
macro_rules! qprintln {
@ -62,167 +62,167 @@ macro_rules! make_qprintln {
// First, with `indent`.
{ indent=$i: expr } => {
if ! $quiet {
wprintln!(indent=$i);
weprintln!(indent=$i);
}
};
{ indent=$i: expr, $a0: expr } => {
if ! $quiet {
wprintln!(indent=$i, $a0);
weprintln!(indent=$i, $a0);
}
};
{ indent=$i: expr, $a0: expr, $a1: expr } => {
if ! $quiet {
wprintln!(indent=$i, $a0, $a1);
weprintln!(indent=$i, $a0, $a1);
}
};
{ indent=$i: expr, $a0: expr, $a1: expr, $a2: expr } => {
if ! $quiet {
wprintln!(indent=$i, $a0, $a1, $a2);
weprintln!(indent=$i, $a0, $a1, $a2);
}
};
{ indent=$i: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr } => {
if ! $quiet {
wprintln!(indent=$i, $a0, $a1, $a2, $a3);
weprintln!(indent=$i, $a0, $a1, $a2, $a3);
}
};
{ indent=$i: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr } => {
if ! $quiet {
wprintln!(indent=$i, $a0, $a1, $a2, $a3, $a4);
weprintln!(indent=$i, $a0, $a1, $a2, $a3, $a4);
}
};
{ indent=$i: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr, $a5: expr } => {
if ! $quiet {
wprintln!(indent=$i, $a0, $a1, $a2, $a3, $a4, $a5);
weprintln!(indent=$i, $a0, $a1, $a2, $a3, $a4, $a5);
}
};
{ indent=$i: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr, $a5: expr, $a6: expr } => {
if ! $quiet {
wprintln!(indent=$i, $a0, $a1, $a2, $a3, $a4, $a5, $a6);
weprintln!(indent=$i, $a0, $a1, $a2, $a3, $a4, $a5, $a6);
}
};
// Again, with `initial_indent` and `subsequent_indent`.
{ initial_indent=$ii: expr, subsequent_indent=$si: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, subsequent_indent=$si);
weprintln!(initial_indent=$ii, subsequent_indent=$si);
}
};
{ initial_indent=$ii: expr, subsequent_indent=$si: expr, $a0: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, subsequent_indent=$si, $a0);
weprintln!(initial_indent=$ii, subsequent_indent=$si, $a0);
}
};
{ initial_indent=$ii: expr, subsequent_indent=$si: expr, $a0: expr, $a1: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1);
weprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1);
}
};
{ initial_indent=$ii: expr, subsequent_indent=$si: expr, $a0: expr, $a1: expr, $a2: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1, $a2);
weprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1, $a2);
}
};
{ initial_indent=$ii: expr, subsequent_indent=$si: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1, $a2, $a3);
weprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1, $a2, $a3);
}
};
{ initial_indent=$ii: expr, subsequent_indent=$si: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1, $a2, $a3, $a4);
weprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1, $a2, $a3, $a4);
}
};
{ initial_indent=$ii: expr, subsequent_indent=$si: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr, $a5: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1, $a2, $a3, $a4, $a5);
weprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1, $a2, $a3, $a4, $a5);
}
};
{ initial_indent=$ii: expr, subsequent_indent=$si: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr, $a5: expr, $a6: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1, $a2, $a3, $a4, $a5, $a6);
weprintln!(initial_indent=$ii, subsequent_indent=$si, $a0, $a1, $a2, $a3, $a4, $a5, $a6);
}
};
// Again, with `initial_indent`.
{ initial_indent=$ii: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii);
weprintln!(initial_indent=$ii);
}
};
{ initial_indent=$ii: expr, $a0: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, $a0);
weprintln!(initial_indent=$ii, $a0);
}
};
{ initial_indent=$ii: expr, $a0: expr, $a1: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, $a0, $a1);
weprintln!(initial_indent=$ii, $a0, $a1);
}
};
{ initial_indent=$ii: expr, $a0: expr, $a1: expr, $a2: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, $a0, $a1, $a2);
weprintln!(initial_indent=$ii, $a0, $a1, $a2);
}
};
{ initial_indent=$ii: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, $a0, $a1, $a2, $a3);
weprintln!(initial_indent=$ii, $a0, $a1, $a2, $a3);
}
};
{ initial_indent=$ii: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, $a0, $a1, $a2, $a3, $a4);
weprintln!(initial_indent=$ii, $a0, $a1, $a2, $a3, $a4);
}
};
{ initial_indent=$ii: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr, $a5: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, $a0, $a1, $a2, $a3, $a4, $a5);
weprintln!(initial_indent=$ii, $a0, $a1, $a2, $a3, $a4, $a5);
}
};
{ initial_indent=$ii: expr, $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr, $a5: expr, $a6: expr } => {
if ! $quiet {
wprintln!(initial_indent=$ii, $a0, $a1, $a2, $a3, $a4, $a5, $a6);
weprintln!(initial_indent=$ii, $a0, $a1, $a2, $a3, $a4, $a5, $a6);
}
};
// Again, without any indent.
{} => {
if ! $quiet {
wprintln!();
weprintln!();
}
};
{ $a0: expr } => {
if ! $quiet {
wprintln!($a0);
weprintln!($a0);
}
};
{ $a0: expr, $a1: expr } => {
if ! $quiet {
wprintln!($a0, $a1);
weprintln!($a0, $a1);
}
};
{ $a0: expr, $a1: expr, $a2: expr } => {
if ! $quiet {
wprintln!($a0, $a1, $a2);
weprintln!($a0, $a1, $a2);
}
};
{ $a0: expr, $a1: expr, $a2: expr, $a3: expr } => {
if ! $quiet {
wprintln!($a0, $a1, $a2, $a3);
weprintln!($a0, $a1, $a2, $a3);
}
};
{ $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr } => {
if ! $quiet {
wprintln!($a0, $a1, $a2, $a3, $a4);
weprintln!($a0, $a1, $a2, $a3, $a4);
}
};
{ $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr, $a5: expr } => {
if ! $quiet {
wprintln!($a0, $a1, $a2, $a3, $a4, $a5);
weprintln!($a0, $a1, $a2, $a3, $a4, $a5);
}
};
{ $a0: expr, $a1: expr, $a2: expr, $a3: expr, $a4: expr, $a5: expr, $a6: expr } => {
if ! $quiet {
wprintln!($a0, $a1, $a2, $a3, $a4, $a5, $a6);
weprintln!($a0, $a1, $a2, $a3, $a4, $a5, $a6);
}
};
}

View File

@ -130,8 +130,8 @@ where
#[allow(dead_code)]
fn help_warning(arg: &str) {
if arg == "help" {
wprintln!("Warning: \"help\" is not a subcommand here. \
Did you mean --help?");
weprintln!("Warning: \"help\" is not a subcommand here. \
Did you mean --help?");
}
}
@ -396,7 +396,7 @@ fn real_main() -> Result<()> {
err.print()?;
if let Some(examples) = command.get_after_help() {
wprintln!("\n{}", examples);
weprintln!("\n{}", examples);
}
} else {
// Ummm... something went wrong: we should be able
@ -476,10 +476,10 @@ fn error_chain(err: &anyhow::Error) -> Vec<String> {
/// Prints the error and causes, if any.
pub fn print_error_chain(err: &anyhow::Error) {
wprintln!();
wprintln!(initial_indent=" Error: ", "{}", err);
weprintln!();
weprintln!(initial_indent=" Error: ", "{}", err);
err.chain().skip(1).for_each(
|cause| wprintln!(initial_indent="because: ", "{}", cause));
|cause| weprintln!(initial_indent="because: ", "{}", cause));
}
/// Returns the error chain as a string.
@ -560,7 +560,7 @@ fn print_examples(cli: &clap::Command, usage: impl ToString) -> Result<()> {
// And print the examples, if any.
if let Some(examples) = cmd.get_after_help() {
wprintln!("\n{}", examples);
weprintln!("\n{}", examples);
}
Ok(())

View File

@ -27,8 +27,8 @@ impl Hint {
/// follows.
pub fn hint(mut self, msg: fmt::Arguments) -> Self {
if ! self.quiet {
wprintln!();
wprintln!(
weprintln!();
weprintln!(
initial_indent=if self.first { "Hint: " } else { " " },
subsequent_indent=" ",
"{}", msg);

View File

@ -70,11 +70,11 @@ impl ImportStats {
self.keys.print_summary()?;
}
wprintln!("Imported {}, updated {}, {} unchanged, {}.",
self.certs.new_certs().of("new certificate"),
self.certs.updated_certs().of("certificate"),
self.certs.unchanged_certs().of("certificate"),
self.certs.errors().of("error"));
weprintln!("Imported {}, updated {}, {} unchanged, {}.",
self.certs.new_certs().of("new certificate"),
self.certs.updated_certs().of("certificate"),
self.certs.unchanged_certs().of("certificate"),
self.certs.errors().of("error"));
Ok(())
}
}
@ -115,11 +115,11 @@ impl KeyStats {
/// Print key and certificate import summary.
pub fn print_summary(&self) -> Result<()> {
wprintln!("Imported {}, updated {}, {} unchanged, {}.",
self.new.of("new key"),
self.updated.of("key"),
self.unchanged.of("key"),
self.errors.of("error"));
weprintln!("Imported {}, updated {}, {} unchanged, {}.",
self.new.of("new key"),
self.updated.of("key"),
self.unchanged.of("key"),
self.errors.of("error"));
Ok(())
}
}

View File

@ -8,9 +8,9 @@ pub const NBSP: char = '\u{00A0}';
/// Prints the given message to stderr.
///
/// Hint: Use `wprintln!(..)` instead of invoking this function
/// Hint: Use `weprintln!(..)` instead of invoking this function
/// directly.
pub fn wprintln(msg: fmt::Arguments) {
pub fn weprintln(msg: fmt::Arguments) {
let m = format!("{}", msg);
for l in textwrap::wrap(&m, options()) {
eprintln!("{}", l);
@ -19,12 +19,12 @@ pub fn wprintln(msg: fmt::Arguments) {
/// Prints the given message to stderr, indenting continuations.
///
/// Hint: Use `wprintln!(indent="...", ..)` or
/// `wprintln!(initial_indent="...", subsequent_indent="...", ..)`
/// Hint: Use `weprintln!(indent="...", ..)` or
/// `weprintln!(initial_indent="...", subsequent_indent="...", ..)`
/// instead of invoking this function directly.
pub fn iwprintln(initial_indent: &str,
subsequent_indent: &str,
msg: fmt::Arguments) {
pub fn iweprintln(initial_indent: &str,
subsequent_indent: &str,
msg: fmt::Arguments) {
let m = format!("{}", msg);
for l in textwrap::wrap(&m,
options()

View File

@ -578,14 +578,14 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
}
if checked_id {
wprintln!("Error: {} does not have a key with \
the required capabilities ({:?})",
cert.keyid(), keyflags);
weprintln!("Error: {} does not have a key with \
the required capabilities ({:?})",
cert.keyid(), keyflags);
} else {
wprintln!("Error: The subkey {} (cert: {}) \
does not the required capabilities \
({:?})",
kh, cert.keyid(), keyflags);
weprintln!("Error: The subkey {} (cert: {}) \
does not the required capabilities \
({:?})",
kh, cert.keyid(), keyflags);
}
return false;
})
@ -683,7 +683,7 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
for userid in userid.iter() {
let matches: Vec<(Fingerprint, UserID)> = if email {
if let Err(err) = UserIDQueryParams::is_email(userid) {
wprintln!("{:?} is not a valid email address", userid);
weprintln!("{:?} is not a valid email address", userid);
if error.is_none() {
error = Some(err);
}
@ -834,16 +834,16 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
}
};
wprintln!("{:?}:\n", err);
weprintln!("{:?}:\n", err);
if error.is_none() {
error = Some(err);
}
// Print the errors.
for (i, Entry { fpr, userid, cert }) in bad.into_iter().enumerate() {
wprintln!("{}. When considering {} ({}):",
i + 1, fpr,
String::from_utf8_lossy(userid.value()));
weprintln!("{}. When considering {} ({}):",
i + 1, fpr,
String::from_utf8_lossy(userid.value()));
let err = match cert {
Ok(_) => unreachable!(),
Err(err) => err,
@ -888,8 +888,8 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
// Not found.
Ok(None) => None,
Err(err) => {
wprintln!("Error looking up local trust root: {}",
err);
weprintln!("Error looking up local trust root: {}",
err);
None
}
}
@ -900,21 +900,21 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
match parser.next() {
Some(Ok(cert)) => Some(cert.fingerprint()),
Some(Err(err)) => {
wprintln!("Local trust root is \
corrupted: {}",
err);
weprintln!("Local trust root is \
corrupted: {}",
err);
None
}
None => {
wprintln!("Local trust root is \
corrupted: no data");
weprintln!("Local trust root is \
corrupted: no data");
None
}
}
}
Err(err) => {
wprintln!("Error parsing local trust root: {}",
err);
weprintln!("Error parsing local trust root: {}",
err);
None
}
}
@ -1262,10 +1262,10 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
return Ok(key);
}
wprintln!("Incorrect password.");
weprintln!("Incorrect password.");
}
Err(err) => {
wprintln!("While reading password: {}", err);
weprintln!("While reading password: {}", err);
break;
}
}
@ -1388,7 +1388,7 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
.is_none()
{
if let Some(hint) = hint {
wprintln!("{}", hint);
weprintln!("{}", hint);
}
loop {
@ -1397,7 +1397,7 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
ka.cert().keyid(), ka.keyid(), uid))?;
if p == "".into() {
wprintln!("Giving up.");
weprintln!("Giving up.");
continue 'key;
}
@ -1407,7 +1407,7 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
break;
}
Err(err) => {
wprintln!("Failed to unlock key: {}", err);
weprintln!("Failed to unlock key: {}", err);
}
}
}
@ -1735,7 +1735,7 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
/// Prints additional information in verbose mode.
pub fn info(&self, msg: fmt::Arguments) {
if self.verbose() {
wprintln!("{}", msg);
weprintln!("{}", msg);
}
}
@ -2284,8 +2284,8 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
let (certs, errors) =
self.resolve_certs(designators, trust_amount)?;
if certs.len() > 1 {
wprintln!("{} is ambiguous. It resolves to multiple certificates.",
designators.designators[0].argument::<Prefix>());
weprintln!("{} is ambiguous. It resolves to multiple certificates.",
designators.designators[0].argument::<Prefix>());
for cert in certs.iter() {
eprintln!(" - {} {}",
cert.fingerprint(),
@ -2354,7 +2354,7 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
let err = format!(
"Selected key {} is a primary key, not a subkey.",
ka.fingerprint());
wprintln!("{}", err);
weprintln!("{}", err);
bad.push(anyhow::anyhow!(err));
continue;
}
@ -2384,7 +2384,7 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
let err = anyhow::anyhow!(
"Can't use {}, it is hard revoked",
ka.fingerprint());
wprintln!("{}", err);
weprintln!("{}", err);
bad.push(err);
} else {
// Looks good!
@ -2404,8 +2404,8 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
Err(err) => err,
};
wprintln!("Selected key {} is unusable: {}.",
fingerprint, err);
weprintln!("Selected key {} is unusable: {}.",
fingerprint, err);
bad.push(err);
@ -2435,8 +2435,8 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
.done();
} else {
// The key isn't bound to the certificate at all.
wprintln!("Selected key {} is not part of the certificate.",
kh);
weprintln!("Selected key {} is not part of the certificate.",
kh);
missing.push(kh);
}
}
@ -2446,15 +2446,15 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
keys.len(), kas.len(), missing.len(), bad.len());
if ! missing.is_empty() {
wprintln!();
weprintln!();
if only_subkeys {
wprintln!("{} has the following subkeys:", vc.fingerprint());
weprintln!("{} has the following subkeys:", vc.fingerprint());
} else {
wprintln!("{} has the following keys:", vc.fingerprint());
weprintln!("{} has the following keys:", vc.fingerprint());
}
wprintln!();
weprintln!();
for ka in vc.keys().skip(if only_subkeys { 1 } else { 0 }) {
wprintln!(" - {}", ka.fingerprint());
weprintln!(" - {}", ka.fingerprint());
}
}