Make the cli's --photo option take arguments

Also update the related zsh autocompletion.
This commit is contained in:
Matthijs Tijink 2019-09-13 16:11:16 +00:00
parent 342e572d90
commit fb174b23e3
2 changed files with 5 additions and 5 deletions

View file

@ -73,7 +73,7 @@ int main(int argc, char** argv)
parser.addOption(QCommandLineOption(QStringLiteral("execute-command"), i18n("Executes a remote command by id"), QStringLiteral("id")));
parser.addOption(QCommandLineOption(QStringList{QStringLiteral("k"), QStringLiteral("send-keys")}, i18n("Sends keys to a said device"), QStringLiteral("key")));
parser.addOption(QCommandLineOption(QStringLiteral("my-id"), i18n("Display this device's id and exit")));
parser.addOption(QCommandLineOption(QStringLiteral("photo"), i18n("Open the connected device's camera and transfer the photo")));
parser.addOption(QCommandLineOption(QStringLiteral("photo"), i18n("Open the connected device's camera and transfer the photo"), QStringLiteral("path")));
//Hidden because it's an implementation detail
QCommandLineOption deviceAutocomplete(QStringLiteral("shell-device-autocompletion"));
@ -270,13 +270,13 @@ int main(int argc, char** argv)
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/findmyphone"), QStringLiteral("org.kde.kdeconnect.device.findmyphone"), QStringLiteral("ring"));
blockOnReply(DBusHelper::sessionBus().asyncCall(msg));
} else if(parser.isSet(QStringLiteral("photo"))) {
if (parser.positionalArguments().size() == 1) {
const QString fileName = parser.positionalArguments()[0];
const QString fileName = parser.value(QStringLiteral("photo"));
if (!fileName.isEmpty()) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/photo"), QStringLiteral("org.kde.kdeconnect.device.photo"), QStringLiteral("requestPhoto"));
msg.setArguments({fileName});
blockOnReply(DBusHelper::sessionBus().asyncCall(msg));
} else {
QTextStream(stderr) << i18n("Please give exactly 1 file name") << endl;
QTextStream(stderr) << i18n("Please specify a filename for the photo") << endl;
}
} else if(parser.isSet(QStringLiteral("send-keys"))) {
QString seq = parser.value(QStringLiteral("send-keys"));

View file

@ -26,7 +26,7 @@ _arguments \
'--execute-command[execute a remote command]:command id' \
'(-k --send-keys)'{-k,--send-keys}'[send keys to the specified device]' \
"--my-id[display this device's id]" \
"--photo[open the connected device's camera and transfer the photo]" \
"--photo[open the connected device's camera and transfer the photo]:file:_files" \
'(-)'{-h,--help}'[display usage information]' \
'(-)'{-v,--version}'[display version information]' \
'(-)--author[show author information and exit]' \