From 7d46ce3de1f96076addeaba646f338fc2e3e2397 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Fri, 19 Apr 2019 16:19:19 -0400 Subject: [PATCH] Correct CLI help messages on Windows * Prevents keepassxc-cli.exe -> keepassxc-cli show.exe * Fixes #3032 --- src/cli/Add.cpp | 2 +- src/cli/Clip.cpp | 2 +- src/cli/Create.cpp | 2 +- src/cli/Diceware.cpp | 4 ++-- src/cli/Edit.cpp | 2 +- src/cli/Estimate.cpp | 2 +- src/cli/Extract.cpp | 2 +- src/cli/Generate.cpp | 4 ++-- src/cli/List.cpp | 2 +- src/cli/Locate.cpp | 2 +- src/cli/Merge.cpp | 2 +- src/cli/Remove.cpp | 2 +- src/cli/Show.cpp | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cli/Add.cpp b/src/cli/Add.cpp index 395b84919..975d549e5 100644 --- a/src/cli/Add.cpp +++ b/src/cli/Add.cpp @@ -84,7 +84,7 @@ int Add::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (args.size() != 2) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli add"); + errorTextStream << parser.helpText().replace("[options]", "add [options]"); return EXIT_FAILURE; } diff --git a/src/cli/Clip.cpp b/src/cli/Clip.cpp index 31b421de6..e1e74c682 100644 --- a/src/cli/Clip.cpp +++ b/src/cli/Clip.cpp @@ -63,7 +63,7 @@ int Clip::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (args.size() != 2 && args.size() != 3) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli clip"); + errorTextStream << parser.helpText().replace("[options]", "clip [options]"); return EXIT_FAILURE; } diff --git a/src/cli/Create.cpp b/src/cli/Create.cpp index b8c094f90..80dcb5691 100644 --- a/src/cli/Create.cpp +++ b/src/cli/Create.cpp @@ -70,7 +70,7 @@ int Create::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (args.size() < 1) { - out << parser.helpText().replace("keepassxc-cli", "keepassxc-cli create"); + out << parser.helpText().replace("[options]", "create [options]"); return EXIT_FAILURE; } diff --git a/src/cli/Diceware.cpp b/src/cli/Diceware.cpp index f11347344..c663cfc39 100644 --- a/src/cli/Diceware.cpp +++ b/src/cli/Diceware.cpp @@ -58,7 +58,7 @@ int Diceware::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (!args.isEmpty()) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli diceware"); + errorTextStream << parser.helpText().replace("[options]", "diceware [options]"); return EXIT_FAILURE; } @@ -78,7 +78,7 @@ int Diceware::execute(const QStringList& arguments) } if (!dicewareGenerator.isValid()) { - outputTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli diceware"); + outputTextStream << parser.helpText().replace("[options]", "diceware [options]"); return EXIT_FAILURE; } diff --git a/src/cli/Edit.cpp b/src/cli/Edit.cpp index 76e996c98..59cedd7c9 100644 --- a/src/cli/Edit.cpp +++ b/src/cli/Edit.cpp @@ -88,7 +88,7 @@ int Edit::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (args.size() != 2) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli edit"); + errorTextStream << parser.helpText().replace("[options]", "edit [options]"); return EXIT_FAILURE; } diff --git a/src/cli/Estimate.cpp b/src/cli/Estimate.cpp index 7064963f4..c278b50f3 100644 --- a/src/cli/Estimate.cpp +++ b/src/cli/Estimate.cpp @@ -171,7 +171,7 @@ int Estimate::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (args.size() > 1) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli estimate"); + errorTextStream << parser.helpText().replace("[options]", "estimate [options]"); return EXIT_FAILURE; } diff --git a/src/cli/Extract.cpp b/src/cli/Extract.cpp index 729687fe3..2e4e6f9cd 100644 --- a/src/cli/Extract.cpp +++ b/src/cli/Extract.cpp @@ -57,7 +57,7 @@ int Extract::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (args.size() != 1) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli extract"); + errorTextStream << parser.helpText().replace("[options]", "extract [options]"); return EXIT_FAILURE; } diff --git a/src/cli/Generate.cpp b/src/cli/Generate.cpp index 5f0ad98ac..e8ca90275 100644 --- a/src/cli/Generate.cpp +++ b/src/cli/Generate.cpp @@ -84,7 +84,7 @@ int Generate::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (!args.isEmpty()) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli generate"); + errorTextStream << parser.helpText().replace("[options]", "generate [options]"); return EXIT_FAILURE; } @@ -128,7 +128,7 @@ int Generate::execute(const QStringList& arguments) passwordGenerator.setExcludedChars(parser.value(exclude)); if (!passwordGenerator.isValid()) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli generate"); + errorTextStream << parser.helpText().replace("[options]", "generate [options]"); return EXIT_FAILURE; } diff --git a/src/cli/List.cpp b/src/cli/List.cpp index ebf7bfda1..52797470c 100644 --- a/src/cli/List.cpp +++ b/src/cli/List.cpp @@ -59,7 +59,7 @@ int List::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (args.size() != 1 && args.size() != 2) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli ls"); + errorTextStream << parser.helpText().replace("[options]", "ls [options]"); return EXIT_FAILURE; } diff --git a/src/cli/Locate.cpp b/src/cli/Locate.cpp index 81bbdd55d..af5f24196 100644 --- a/src/cli/Locate.cpp +++ b/src/cli/Locate.cpp @@ -56,7 +56,7 @@ int Locate::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (args.size() != 2) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli locate"); + errorTextStream << parser.helpText().replace("[options]", "locate [options]"); return EXIT_FAILURE; } diff --git a/src/cli/Merge.cpp b/src/cli/Merge.cpp index a7357394f..2356f5d3a 100644 --- a/src/cli/Merge.cpp +++ b/src/cli/Merge.cpp @@ -69,7 +69,7 @@ int Merge::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (args.size() != 2) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli merge"); + errorTextStream << parser.helpText().replace("[options]", "merge [options]"); return EXIT_FAILURE; } diff --git a/src/cli/Remove.cpp b/src/cli/Remove.cpp index 07da23b7b..bb2374e9a 100644 --- a/src/cli/Remove.cpp +++ b/src/cli/Remove.cpp @@ -58,7 +58,7 @@ int Remove::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (args.size() != 2) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli rm"); + errorTextStream << parser.helpText().replace("[options]", "rm [options]"); return EXIT_FAILURE; } diff --git a/src/cli/Show.cpp b/src/cli/Show.cpp index d16fbfe3c..3abccd79c 100644 --- a/src/cli/Show.cpp +++ b/src/cli/Show.cpp @@ -69,7 +69,7 @@ int Show::execute(const QStringList& arguments) const QStringList args = parser.positionalArguments(); if (args.size() != 2) { - errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli show"); + errorTextStream << parser.helpText().replace("[options]", "show [options]"); return EXIT_FAILURE; }