put more stuff in Meta to simplify

This commit is contained in:
isanae
2021-01-18 08:20:08 -05:00
parent 65a9e51e0e
commit 06109a568b
2 changed files with 42 additions and 50 deletions
+33 -34
View File
@@ -438,6 +438,11 @@ std::string CommandLine::more() const
}
Command::Meta::Meta(std::string n, std::string d, std::string u, std::string m)
: name(n), description(d), usage(u), more(m)
{
}
std::string Command::name() const
{
return meta().name;
@@ -450,12 +455,12 @@ std::string Command::description() const
std::string Command::usageLine() const
{
return name() + " " + getUsageLine();
return name() + " " + meta().usage;
}
std::string Command::moreInfo() const
{
return getMoreInfo();
return meta().more;
}
po::options_description Command::allOptions() const
@@ -488,16 +493,6 @@ bool Command::legacy() const
return false;
}
std::string Command::getUsageLine() const
{
return "[options]";
}
std::string Command::getMoreInfo() const
{
return "";
}
po::options_description Command::getVisibleOptions() const
{
// no-op
@@ -574,7 +569,12 @@ po::options_description CrashDumpCommand::getVisibleOptions() const
Command::Meta CrashDumpCommand::meta() const
{
return {"crashdump", "writes a crashdump for a running process of MO"};
return {
"crashdump",
"writes a crashdump for a running process of MO",
"[options]",
""
};
}
std::optional<int> CrashDumpCommand::runEarly()
@@ -599,7 +599,7 @@ std::optional<int> CrashDumpCommand::runEarly()
Command::Meta LaunchCommand::meta() const
{
return {"launch", "(internal, do not use)"};
return {"launch", "(internal, do not use)", "", ""};
}
bool LaunchCommand::legacy() const
@@ -673,18 +673,18 @@ LPCWSTR LaunchCommand::UntouchedCommandLineArguments(
}
std::string RunCommand::getUsageLine() const
Command::Meta RunCommand::meta() const
{
return "[options] NAME";
}
return {
"run",
"runs a program, file or a configured executable",
"[options] NAME",
std::string RunCommand::getMoreInfo() const
{
return
"Runs a program or a file with the virtual filesystem. If NAME is a path\n"
"to a non-executable file, the program that is associated with the file\n"
"extension is run instead. With -e, NAME must refer to the name of an\n"
"executable in the instance (for example, \"SKSE\").";
"executable in the instance (for example, \"SKSE\")."
};
}
po::options_description RunCommand::getVisibleOptions() const
@@ -718,11 +718,6 @@ po::positional_options_description RunCommand::getPositional() const
return d;
}
Command::Meta RunCommand::meta() const
{
return {"run", "runs a program, file or a configured executable"};
}
bool RunCommand::canForwardToPrimary() const
{
return true;
@@ -787,9 +782,14 @@ std::optional<int> RunCommand::runPostOrganizer(OrganizerCore& core)
std::string ReloadPluginCommand::getUsageLine() const
Command::Meta ReloadPluginCommand::meta() const
{
return "PLUGIN";
return {
"reload-plugin",
"reloads the given plugin",
"PLUGIN",
""
};
}
po::options_description ReloadPluginCommand::getInternalOptions() const
@@ -811,11 +811,6 @@ po::positional_options_description ReloadPluginCommand::getPositional() const
return d;
}
Command::Meta ReloadPluginCommand::meta() const
{
return {"reload-plugin", "reloads the given plugin"};
}
bool ReloadPluginCommand::canForwardToPrimary() const
{
return true;
@@ -839,7 +834,11 @@ std::optional<int> ReloadPluginCommand::runPostOrganizer(OrganizerCore& core)
Command::Meta RefreshCommand::meta() const
{
return {"refresh", "refreshes MO (same as F5)"};
return {
"refresh",
"refreshes MO (same as F5)",
"", ""
};
}
bool RefreshCommand::canForwardToPrimary() const
+9 -16
View File
@@ -28,11 +28,11 @@ public:
//
std::string description() const;
// usage line, puts together the name and whatever getUsageLine() returns
// usage line, puts together the name and whatever meta().usage is
//
std::string usageLine() const;
// shown after the usage line
// shown after the usage line; this is meta().more
//
std::string moreInfo() const;
@@ -74,17 +74,13 @@ protected:
//
struct Meta
{
std::string name, description;
std::string name, description, usage, more;
Meta(
std::string name, std::string description,
std::string usage, std::string more);
};
// returns the usage line for this command, not including the name
//
virtual std::string getUsageLine() const;
// returns text shown after the usage line
//
virtual std::string getMoreInfo() const;
// returns visible options specific to this command
//
virtual po::options_description getVisibleOptions() const;
@@ -166,13 +162,11 @@ protected:
class RunCommand : public Command
{
protected:
std::string getUsageLine() const override;
std::string getMoreInfo() const override;
Meta meta() const override;
po::options_description getVisibleOptions() const override;
po::options_description getInternalOptions() const override;
po::positional_options_description getPositional() const override;
Meta meta() const override;
bool canForwardToPrimary() const override;
std::optional<int> runPostOrganizer(OrganizerCore& core) override;
@@ -184,11 +178,10 @@ protected:
class ReloadPluginCommand : public Command
{
protected:
std::string getUsageLine() const override;
Meta meta() const override;
po::options_description getInternalOptions() const override;
po::positional_options_description getPositional() const override;
Meta meta() const override;
bool canForwardToPrimary() const override;
std::optional<int> runPostOrganizer(OrganizerCore& core) override;