Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change text references from "arguments" to "subcommands" #3360

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading