Skip to content

Commit

Permalink
Change text references from "arguments" to "subcommands" (#3360)
Browse files Browse the repository at this point in the history
  • Loading branch information
toadkarter authored Oct 9, 2023
1 parent 06cfa58 commit a8a3fd9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
30 changes: 15 additions & 15 deletions src/cli/commandlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ auto helpOption =
CommandOption({ "h", "help" }, QStringLiteral("Displays this help"));

QString optionsToString(const QList<CommandOption>& options,
const QList<CommandArgument>& arguments)
const QList<CommandArgument>& subcommands)
{
int size = 0; // track the largest size
QStringList dashedOptionList;
Expand All @@ -42,10 +42,10 @@ QString optionsToString(const QList<CommandOption>& options,
}
dashedOptionList << joinedDashedOptions;
}
// check the length of the arguments
for (auto const& arg : arguments) {
if (arg.name().length() > size) {
size = arg.name().length();
// check the length of the subcommands
for (auto const& subcommand : subcommands) {
if (subcommand.name().length() > size) {
size = subcommand.name().length();
}
}
// generate the text
Expand All @@ -60,17 +60,17 @@ QString optionsToString(const QList<CommandOption>& options,
.arg(options.at(i).description().replace(
QLatin1String("\n"), linePadding));
}
if (!arguments.isEmpty()) {
if (!subcommands.isEmpty()) {
result += QLatin1String("\n");
}
}
if (!arguments.isEmpty()) {
result += QObject::tr("Arguments") + ":\n";
if (!subcommands.isEmpty()) {
result += QObject::tr("Subcommands") + ":\n";
}
for (const auto& argument : arguments) {
for (const auto& subcommand : subcommands) {
result += QStringLiteral(" %1 %2\n")
.arg(argument.name().leftJustified(size, ' '))
.arg(argument.description());
.arg(subcommand.name().leftJustified(size, ' '))
.arg(subcommand.description());
}
return result;
}
Expand Down Expand Up @@ -326,7 +326,7 @@ void CommandLineParser::printHelp(QStringList args, const Node* node)
argName = qApp->applicationName();
}
QString argText =
node->subNodes.isEmpty() ? "" : "[" + QObject::tr("arguments") + "]";
node->subNodes.isEmpty() ? "" : "[" + QObject::tr("subcommands") + "]";
helpText += (QObject::tr("Usage") + ": %1 [%2-" + QObject::tr("options") +
QStringLiteral("] %3\n\n"))
.arg(args.join(QStringLiteral(" ")))
Expand All @@ -339,9 +339,9 @@ void CommandLineParser::printHelp(QStringList args, const Node* node)
helpText += "\n\n";

// add command options and subarguments
QList<CommandArgument> subArgs;
QList<CommandArgument> subcommands;
for (const Node& n : node->subNodes) {
subArgs.append(n.argument);
subcommands.append(n.argument);
}
auto modifiedOptions = node->options;
if (m_withHelp) {
Expand All @@ -350,7 +350,7 @@ void CommandLineParser::printHelp(QStringList args, const Node* node)
if (m_withVersion && node == &m_parseTree) {
modifiedOptions << versionOption;
}
helpText += optionsToString(modifiedOptions, subArgs);
helpText += optionsToString(modifiedOptions, subcommands);
// print it
out << helpText;
}
Expand Down
10 changes: 6 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,19 @@ int main(int argc, char* argv[])
QObject::tr("Powerful yet simple to use screenshot software."));
parser.setGeneralErrorMessage(QObject::tr("See") + " flameshot --help.");
// Arguments
CommandArgument fullArgument(QStringLiteral("full"),
QObject::tr("Capture the entire desktop."));
CommandArgument fullArgument(
QStringLiteral("full"),
QObject::tr("Capture screenshot of all monitors at the same time."));
CommandArgument launcherArgument(QStringLiteral("launcher"),
QObject::tr("Open the capture launcher."));
CommandArgument guiArgument(
QStringLiteral("gui"),
QObject::tr("Start a manual capture in GUI mode."));
CommandArgument configArgument(QStringLiteral("config"),
QObject::tr("Configure") + " flameshot.");
CommandArgument screenArgument(QStringLiteral("screen"),
QObject::tr("Capture a single screen."));
CommandArgument screenArgument(
QStringLiteral("screen"),
QObject::tr("Capture a screenshot of the specified monitor."));

// Options
CommandOption pathOption(
Expand Down

0 comments on commit a8a3fd9

Please sign in to comment.