-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
cli: show: add --attributes flag #1289
Conversation
For this PR and the other can you significantly shorten the commit log message. Its not meant to be a play by play. |
How much shorter would you like? I guess I'm just used to the kernel commit style, where the explanation of a patch is part of the commit (rather than it being a separate PR description). I'm also a little confused why it would matter all too much -- most |
@droidmonkey what's wrong with detailed commit messages? |
@cyphar I'm happy that you give feedback (and contribute) on the CLI! I added the main commands some time ago and did not receive that much feedback since then. Can you add a screenshot of the output with the default attributes and with custom attributes? |
src/cli/Show.cpp
Outdated
@@ -49,6 +49,13 @@ int Show::execute(QStringList arguments) | |||
QObject::tr("Key file of the database."), | |||
QObject::tr("path")); | |||
parser.addOption(keyFile); | |||
QCommandLineOption fields(QStringList() << "a" | |||
<< "show-attribute", |
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.
@cyphar what about -a
and --attributes
? I find it redundant to have both the show
command and show
in the name of the option.
src/cli/Show.cpp
Outdated
@@ -49,6 +49,13 @@ int Show::execute(QStringList arguments) | |||
QObject::tr("Key file of the database."), | |||
QObject::tr("path")); | |||
parser.addOption(keyFile); | |||
QCommandLineOption fields(QStringList() << "a" | |||
<< "show-attribute", | |||
QObject::tr("Attribute name to extract and output. " |
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.
@cyphar what about names of the attributes to show
, since show
is the name of the command.
@louib Fixed your comments, and added screenshots. The only question is whether we should provide a way to get a list of attributes. |
As an aside, we really should also allow people to provide passwords in a non-interactive manner (like a password file, which can be made secure by a user by using a FIFO or process substitution). |
src/cli/Show.cpp
Outdated
if (showAttributeNames) { | ||
outputTextStream << attribute << ": "; | ||
} | ||
outputTextStream << entry->attributes()->value(attribute) << endl; |
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.
@cyphar what's the behaviour when that attribute does not exist?
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.
At the moment it will output nothing I believe, but we should be erroring out and doing a return EXIT_FAILURE
.
You mean using a comma separated list of attributes?
Can you open an issue for that please? One last comment on your PR, otherwise 👍 |
At the moment, you can get more than one attribute by specifying What I meant by "get a list of attributes" is to do something like
But maybe I should propose this separately.
Will do. I've opened #1297. |
Sorry i was looking at the commits using FastHub which doesnt distinguish the first line from subsequent. I thought you had run on the first line. Carry on with your excellent contributions! 😁 |
In order for scripting to be much simpler with `keepassxc-cli show`, provide a simple --attributesk API which effectively is just a CLI interface for entry->attributes()->value(...). This allows for more extensibility and prevents changes in our output formatting from breaking existing users of keepassxc-cli (if they use --attributes). Signed-off-by: Aleksa Sarai <[email protected]>
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.
@cyphar thanks for the contribution!
In order for scripting to be much simpler with
keepassxc-cli show
,provide a simple --show-attribute API which effectively is just a CLI
interface for entry->attributes()->value(...). This allows for more
extensibility and prevents changes in our output formatting from
breaking existing users of keepassxc-cli (if they use --show-attribute).
Signed-off-by: Aleksa Sarai [email protected]
Motivation and context
I've recently started scripting around
keepassxc-cli
and I wanted to be able to extract particular fields (especially custom attribute fields) and to avoid having to parse the (unstable) output format.How has this been tested?
I tested this on my machine with my existing database. It suffers from #1260, but once #1280 is merged this could be rebased.
Screenshots (if appropriate):
Types of changes
Checklist:
-DWITH_ASAN=ON
. [REQUIRED]