mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-27 00:09:53 -05:00
Abort CLI open on error
This commit is contained in:
parent
0413662136
commit
5e68cd2fa2
@ -138,10 +138,12 @@ QSharedPointer<QCommandLineParser> Command::getCommandLineParser(const QStringLi
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (parser->positionalArguments().size() < positionalArguments.size()) {
|
if (parser->positionalArguments().size() < positionalArguments.size()) {
|
||||||
|
err << QObject::tr("Missing positional argument(s).") << "\n\n";
|
||||||
err << getHelpText();
|
err << getHelpText();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (parser->positionalArguments().size() > (positionalArguments.size() + optionalArguments.size())) {
|
if (parser->positionalArguments().size() > (positionalArguments.size() + optionalArguments.size())) {
|
||||||
|
err << QObject::tr("Too many arguments provided.") << "\n\n";
|
||||||
err << getHelpText();
|
err << getHelpText();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ private:
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void enterInteractiveMode(const QStringList& arguments)
|
int enterInteractiveMode(const QStringList& arguments)
|
||||||
{
|
{
|
||||||
auto& err = Utils::STDERR;
|
auto& err = Utils::STDERR;
|
||||||
// Replace command list with interactive version
|
// Replace command list with interactive version
|
||||||
@ -118,7 +118,9 @@ void enterInteractiveMode(const QStringList& arguments)
|
|||||||
Open openCmd;
|
Open openCmd;
|
||||||
QStringList openArgs(arguments);
|
QStringList openArgs(arguments);
|
||||||
openArgs.removeFirst();
|
openArgs.removeFirst();
|
||||||
openCmd.execute(openArgs);
|
if (openCmd.execute(openArgs) != EXIT_SUCCESS) {
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
};
|
||||||
|
|
||||||
QScopedPointer<LineReader> reader;
|
QScopedPointer<LineReader> reader;
|
||||||
#if defined(USE_READLINE)
|
#if defined(USE_READLINE)
|
||||||
@ -165,6 +167,8 @@ void enterInteractiveMode(const QStringList& arguments)
|
|||||||
if (currentDatabase) {
|
if (currentDatabase) {
|
||||||
currentDatabase->releaseData();
|
currentDatabase->releaseData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
@ -224,8 +228,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
QString commandName = parser.positionalArguments().at(0);
|
QString commandName = parser.positionalArguments().at(0);
|
||||||
if (commandName == "open") {
|
if (commandName == "open") {
|
||||||
enterInteractiveMode(arguments);
|
return enterInteractiveMode(arguments);
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto command = Commands::getCommand(commandName);
|
auto command = Commands::getCommand(commandName);
|
||||||
|
Loading…
Reference in New Issue
Block a user