diff --git a/CHANGELOG b/CHANGELOG index 95171043b1..3e9fa0d513 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ - Drop to background when copy feature [#3253] - Fix password generator issues with special characters [#3303] - CLI: Add '--format' option and CSV support to the 'extract' command [#3277] +- 💥💥 CLI: Renamed command `extract` -> `export`. [#3277] 2.4.3 (2019-06-12) ========================= diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index f75d6c6f2d..4a8b28c3b7 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -23,7 +23,7 @@ set(cli_SOURCES Diceware.cpp Edit.cpp Estimate.cpp - Extract.cpp + Export.cpp Generate.cpp List.cpp Locate.cpp diff --git a/src/cli/Command.cpp b/src/cli/Command.cpp index b1d5881a05..fdea26e65f 100644 --- a/src/cli/Command.cpp +++ b/src/cli/Command.cpp @@ -29,7 +29,7 @@ #include "Diceware.h" #include "Edit.h" #include "Estimate.h" -#include "Extract.h" +#include "Export.h" #include "Generate.h" #include "List.h" #include "Locate.h" @@ -114,7 +114,7 @@ void populateCommands() commands.insert(QString("diceware"), new Diceware()); commands.insert(QString("edit"), new Edit()); commands.insert(QString("estimate"), new Estimate()); - commands.insert(QString("extract"), new Extract()); + commands.insert(QString("export"), new Export()); commands.insert(QString("generate"), new Generate()); commands.insert(QString("locate"), new Locate()); commands.insert(QString("ls"), new List()); diff --git a/src/cli/Extract.cpp b/src/cli/Export.cpp similarity index 72% rename from src/cli/Extract.cpp rename to src/cli/Export.cpp index 97497e7692..77acaf8067 100644 --- a/src/cli/Extract.cpp +++ b/src/cli/Export.cpp @@ -18,37 +18,38 @@ #include #include -#include "Extract.h" +#include "Export.h" #include "cli/TextStream.h" #include "cli/Utils.h" #include "core/Database.h" #include "format/CsvExporter.h" -const QCommandLineOption Extract::FormatOption = +const QCommandLineOption Export::FormatOption = QCommandLineOption(QStringList() << "f" << "format", - QObject::tr("Format to use when extracting. Available choices are xml or csv. Defaults to xml."), + QObject::tr("Format to use when exporting. Available choices are xml or csv. Defaults to xml."), QObject::tr("xml|csv")); -Extract::Extract() +Export::Export() { - name = QString("extract"); - options.append(Extract::FormatOption); - description = QObject::tr("Extract and print the content of a database."); + name = QString("export"); + options.append(Export::FormatOption); + description = QObject::tr("Exports the content of a database to standard output in the specified format."); } -int Extract::executeWithDatabase(QSharedPointer database, QSharedPointer parser) + +int Export::executeWithDatabase(QSharedPointer database, QSharedPointer parser) { TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly); TextStream errorTextStream(Utils::STDERR, QIODevice::WriteOnly); - QString format = parser->value(Extract::FormatOption); + QString format = parser->value(Export::FormatOption); if (format.isEmpty() || format == QString("xml")) { QByteArray xmlData; QString errorMessage; if (!database->extract(xmlData, &errorMessage)) { - errorTextStream << QObject::tr("Unable to extract database to XML: %1").arg(errorMessage) << endl; + errorTextStream << QObject::tr("Unable to export database to XML: %1").arg(errorMessage) << endl; return EXIT_FAILURE; } outputTextStream << xmlData.constData() << endl; diff --git a/src/cli/Extract.h b/src/cli/Export.h similarity index 86% rename from src/cli/Extract.h rename to src/cli/Export.h index 5d66259324..f7f5b86821 100644 --- a/src/cli/Extract.h +++ b/src/cli/Export.h @@ -15,19 +15,19 @@ * along with this program. If not, see . */ -#ifndef KEEPASSXC_EXTRACT_H -#define KEEPASSXC_EXTRACT_H +#ifndef KEEPASSXC_EXPORT_H +#define KEEPASSXC_EXPORT_H #include "DatabaseCommand.h" -class Extract : public DatabaseCommand +class Export : public DatabaseCommand { public: - Extract(); + Export(); int executeWithDatabase(QSharedPointer db, QSharedPointer parser) override; static const QCommandLineOption FormatOption; }; -#endif // KEEPASSXC_EXTRACT_H +#endif // KEEPASSXC_EXPORT_H diff --git a/src/cli/keepassxc-cli.1 b/src/cli/keepassxc-cli.1 index 23c09bfecf..96ca9325c0 100644 --- a/src/cli/keepassxc-cli.1 +++ b/src/cli/keepassxc-cli.1 @@ -34,8 +34,8 @@ Edits a database entry. A password can be generated (\fI-g\fP option), or a prom .IP "estimate [options] [password]" Estimates the entropy of a password. The password to estimate can be provided as a positional argument, or using the standard input. -.IP "extract [options] " -Extracts and prints the contents of a database to standard output in the specified format (defaults to XML). +.IP "export [options] " +Exports the content of a database to standard output in the specified format (defaults to XML). .IP "generate [options]" Generate a random password. @@ -163,10 +163,10 @@ otherwise the program will fail. If the wordlist has < 4000 words a warning will be printed to STDERR. -.SS "Extract options" +.SS "Export options" .IP "-f, --format" -Format to use when extracting. Available choices are xml or csv. Defaults to xml. +Format to use when exporting. Available choices are xml or csv. Defaults to xml. .SS "List options" diff --git a/tests/TestCli.cpp b/tests/TestCli.cpp index d1bbefd21f..56885bdadd 100644 --- a/tests/TestCli.cpp +++ b/tests/TestCli.cpp @@ -39,7 +39,7 @@ #include "cli/Diceware.h" #include "cli/Edit.h" #include "cli/Estimate.h" -#include "cli/Extract.h" +#include "cli/Export.h" #include "cli/Generate.h" #include "cli/List.h" #include "cli/Locate.h" @@ -170,7 +170,7 @@ void TestCli::testCommand() QVERIFY(Command::getCommand("diceware")); QVERIFY(Command::getCommand("edit")); QVERIFY(Command::getCommand("estimate")); - QVERIFY(Command::getCommand("extract")); + QVERIFY(Command::getCommand("export")); QVERIFY(Command::getCommand("generate")); QVERIFY(Command::getCommand("locate")); QVERIFY(Command::getCommand("ls")); @@ -655,14 +655,14 @@ void TestCli::testEstimate() } } -void TestCli::testExtract() +void TestCli::testExport() { - Extract extractCmd; - QVERIFY(!extractCmd.name.isEmpty()); - QVERIFY(extractCmd.getDescriptionLine().contains(extractCmd.name)); + Export exportCmd; + QVERIFY(!exportCmd.name.isEmpty()); + QVERIFY(exportCmd.getDescriptionLine().contains(exportCmd.name)); Utils::Test::setNextPassword("a"); - extractCmd.execute({"extract", m_dbFile->fileName()}); + exportCmd.execute({"export", m_dbFile->fileName()}); m_stdoutFile->seek(0); m_stdoutFile->readLine(); // skip prompt line @@ -683,7 +683,7 @@ void TestCli::testExtract() qint64 pos = m_stdoutFile->pos(); qint64 posErr = m_stderrFile->pos(); Utils::Test::setNextPassword("a"); - extractCmd.execute({"extract", "-f", "xml", "-q", m_dbFile->fileName()}); + exportCmd.execute({"export", "-f", "xml", "-q", m_dbFile->fileName()}); m_stdoutFile->seek(pos); m_stderrFile->seek(posErr); reader.readDatabase(m_stdoutFile.data(), dbQuiet.data()); @@ -691,11 +691,11 @@ void TestCli::testExtract() QVERIFY(db.data()); QCOMPARE(m_stderrFile->readAll(), QByteArray("")); - // CSV extraction + // CSV exporting pos = m_stdoutFile->pos(); posErr = m_stderrFile->pos(); Utils::Test::setNextPassword("a"); - extractCmd.execute({"extract", "-f", "csv", m_dbFile->fileName()}); + exportCmd.execute({"export", "-f", "csv", m_dbFile->fileName()}); m_stdoutFile->seek(pos); m_stdoutFile->readLine(); // skip prompt line m_stderrFile->seek(posErr); @@ -710,7 +710,7 @@ void TestCli::testExtract() pos = m_stdoutFile->pos(); posErr = m_stderrFile->pos(); Utils::Test::setNextPassword("a"); - extractCmd.execute({"extract", "-f", "yaml", m_dbFile->fileName()}); + exportCmd.execute({"export", "-f", "yaml", m_dbFile->fileName()}); m_stdoutFile->seek(pos); m_stdoutFile->readLine(); // skip prompt line m_stderrFile->seek(posErr); diff --git a/tests/TestCli.h b/tests/TestCli.h index dcc84c2e36..0ad1554473 100644 --- a/tests/TestCli.h +++ b/tests/TestCli.h @@ -52,7 +52,7 @@ private slots: void testEdit(); void testEstimate_data(); void testEstimate(); - void testExtract(); + void testExport(); void testGenerate_data(); void testGenerate(); void testKeyFileOption();