-
-
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
Add open command, interactive CLI session support #3426
Conversation
dd55a71
to
f1bf156
Compare
7f8af3e
to
63fedb7
Compare
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.
Thanks for the PR @sjamesr , I'm glad to see such a major contribution to the CLI!
Out of curiosity, have you thought about a session based approach, were the process with the unlocked (or partially unlocked) database would be spawned first, and then the next commands would be piped/sent to that running process?
I think we would need tests specifically for the 2 new commands, including tests to commands with a current database.
Also, don't forget to update the man page cli/keepassxc-cli.1
and the CHANGELOG!
8df4f2b
to
92e67f2
Compare
92e67f2
to
a9127e6
Compare
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.
Thank you, this looks like a great new feature. Here's my review.
ec27e48
to
b74926c
Compare
b74926c
to
8f23c0e
Compare
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 is great, but a couple of minor changes (while in the "open" terminal prompt only) will make it even better:
- Disable the extract command, it just dumps XML to the view and doesn't let you write to a file
- Add
exit
andquit
keywords that closes the session and returns to bash - Add
close
keyword that closes the current database and returns to the interactive prompt (currently barewordopen
does this as well) - Instead of list the relative path to the database file, just show the database file name (if present) or filename if not.
- Check if the database file exists (using Canonical File Path) prior to requesting unlock password
NOTE: we will have to add libreadline.dylib to the MacOS App Bundle fixups. I don't have the full pathname handy right now. |
606d29a
to
f1322f9
Compare
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 added the improvements you requested, with the exception of disabling the extract
command. Currently there's no way to have a command enabled only in non-interactive mode. Can we add this in a later change?
f1322f9
to
98b7b47
Compare
I wasn't intending for you to make "close", "quit" and "exit" actual commands. Just keywords that would be intercepted in the while loop before the Command::getCommand() call. You can do the same thing with "extract" by intercepting that and telling the user that it is disabled in interactive mode. |
Ok, I can revert that part. Kind of nice to have entries in the generated
help though.
…On Wed, Sep 4, 2019, 7:46 PM Jonathan White ***@***.***> wrote:
I wasn't intending for you to make "close", "quit" and "exit" actual
commands. Just keywords that would be intercepted in the while loop.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3426?email_source=notifications&email_token=ABDNGA3HIMM7U3724TGLXLTQIBXH5A5CNFSM4IJPMBT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD55UL4Y#issuecomment-528172531>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABDNGA2P6LW4IAKWUYJLFGDQIBXH5ANCNFSM4IJPMBTQ>
.
|
Oh good point, let me think about it a little |
4bd6336
to
8e43f58
Compare
I don't like that we populate the command list with interactive mode only commands. In the populateCommands() function, can we only add close, quit, and exit if we are in interactive mode? This would also let you remove extract while in interactive mode. |
9b7c568
to
505cf01
Compare
@droidmonkey I added a separate "Commands" class that has the set of commands that we're using, please take a look. |
Very nice fix, this is now ready for merge |
ff3e518
to
a78aeba
Compare
I updated how we handle commands, batch vs interactive, to comply with our coding standards. Need to add the readline dylib path conversion and this will be ready. |
a78aeba
to
e8bc572
Compare
This change adds a GNU Readline-based interactive mode to keepassxc-cli. If GNU Readline is not available, commands are just read from stdin with no editing or auto-complete support. DatabaseCommand is modified to add the path to the current database to the arguments passed to executeWithDatabase. In this way, instances of DatabaseCommand do not have to prompt to re-open the database after each invocation, and existing command implementations do not have to be changed to support interactive mode. This change also introduces a new way of handling commands between interactive and batch modes. * Fixes keepassxreboot#3224. * Ran make format
e8bc572
to
624bd2c
Compare
I've confirmed that the macOS build uses built-in libraries for the readline so no need to worry about the name tool fixes. |
Other changes: * Use cmake 1.1 port group * Use new cxx_standard * A new feature [1] requires readline [1] keepassxreboot/keepassxc#3426
Type of change
Description and Context
This change adds an interactive mode to
keepassxc-cli
. For example:This change adds the following command:
open
. Ifopen
is invoked, thekeepassxc-cli
program attempts to open the database, then drops into interactive mode.Interactive mode uses readline (falls back to just reading stdin if readline is not available). Each user command causes processing much like keepassxc-cli does today, except the command being invoked already has a database present, meaning the command should not attempt to open any database. I've changed the List and Show commands as examples.
Fixes #3224.
Screenshots
Testing strategy
Checklist: