Adding top-level fields to CLI commands

The top-level fields are currently not accessible from the CLI, which
makes it impossible to select entries or groups based on the UUID.
There are other top-level fields I believe, like the expiry date,
but I only added the two most critical fields for the moment.
This commit is contained in:
louib 2022-07-05 09:07:39 -04:00 committed by Jonathan White
parent a6d3f973fa
commit aa839e2619
6 changed files with 57 additions and 4 deletions

View file

@ -81,11 +81,22 @@ int Show::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<
bool showDefaultAttributes = attributes.isEmpty() && !showTotp;
if (showDefaultAttributes) {
attributes = EntryAttributes::DefaultAttributes;
for (QString fieldName : Utils::EntryFieldNames) {
attributes.append(fieldName);
}
}
// Iterate over the attributes and output them line-by-line.
bool encounteredError = false;
for (const QString& attributeName : asConst(attributes)) {
if (Utils::EntryFieldNames.contains(attributeName)) {
if (showDefaultAttributes) {
out << attributeName << ": ";
}
out << Utils::getTopLevelField(entry, attributeName) << endl;
continue;
}
QStringList attrs = Utils::findAttributes(*entry->attributes(), attributeName);
if (attrs.isEmpty()) {
encounteredError = true;