CLI: Add interactive session mode command open

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 #3224.
* Ran make format
This commit is contained in:
James Ring
2019-09-13 09:49:03 -04:00
committed by Jonathan White
parent a07ea12ac4
commit b1eda37cca
27 changed files with 2751 additions and 2015 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -43,11 +43,13 @@ private slots:
void cleanup();
void cleanupTestCase();
void testCommand();
void testBatchCommands();
void testAdd();
void testAddGroup();
void testAnalyze();
void testClip();
void testCommandParsing_data();
void testCommandParsing();
void testCreate();
void testDiceware();
void testEdit();
@@ -58,10 +60,13 @@ private slots:
void testGenerate();
void testKeyFileOption();
void testNoPasswordOption();
void testHelp();
void testInteractiveCommands();
void testList();
void testLocate();
void testMerge();
void testMove();
void testOpen();
void testRemove();
void testRemoveGroup();
void testRemoveQuiet();

View File

@@ -1214,7 +1214,6 @@ void TestMerge::testCustomData()
QCOMPARE(dbDestination->metadata()->customData()->value("key3"),
QString("newValue")); // Old value should be replaced
// Merging again should not do anything if the values are the same.
m_clock->advanceSecond(1);
dbSource->metadata()->customData()->set("key3", "oldValue");
@@ -1223,7 +1222,6 @@ void TestMerge::testCustomData()
QStringList changes2 = merger2.merge();
QVERIFY(changes2.isEmpty());
Merger merger3(dbSource2.data(), dbDestination2.data());
merger3.merge();

View File

@@ -26,8 +26,8 @@
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QPushButton>
#include <QToolBar>
#include <QTableView>
#include <QToolBar>
#include "config-keepassx-tests.h"
#include "core/Bootstrap.h"
@@ -144,7 +144,7 @@ void TestGuiBrowser::testEntrySettings()
QTest::mouseClick(entryEditWidget, Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::Mode::EditMode);
auto* editEntryWidget = m_dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
// Switch to Properties page and select all rows from the custom data table
editEntryWidget->setCurrentPage(4);
auto customDataTableView = editEntryWidget->findChild<QTableView*>("customDataTable");
@@ -181,9 +181,9 @@ void TestGuiBrowser::triggerAction(const QString& name)
}
void TestGuiBrowser::clickIndex(const QModelIndex& index,
QAbstractItemView* view,
Qt::MouseButton button,
Qt::KeyboardModifiers stateKey)
QAbstractItemView* view,
Qt::MouseButton button,
Qt::KeyboardModifiers stateKey)
{
QTest::mouseClick(view->viewport(), button, stateKey, view->visualRect(index).center());
}