summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2021-01-11 01:54:25 -0500
committerisanae <14251494+isanae@users.noreply.github.com>2021-01-18 08:20:08 -0500
commit06109a568be5d31ebb3303b4702dec7185f22066 (patch)
treefe0b95c66f2d43ddd3f9449ea7949560cd8dc004
parent65a9e51e0ed8169bbf2a176ce147ca5a9ae09a6f (diff)
put more stuff in Meta to simplify
-rw-r--r--src/commandline.cpp67
-rw-r--r--src/commandline.h25
2 files changed, 42 insertions, 50 deletions
diff --git a/src/commandline.cpp b/src/commandline.cpp
index 01ee866e..10d0f1fd 100644
--- a/src/commandline.cpp
+++ b/src/commandline.cpp
@@ -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
diff --git a/src/commandline.h b/src/commandline.h
index 9cad4c71..a92ef094 100644
--- a/src/commandline.h
+++ b/src/commandline.h
@@ -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,16 +74,12 @@ protected:
//
struct Meta
{
- std::string name, description;
- };
-
- // returns the usage line for this command, not including the name
- //
- virtual std::string getUsageLine() const;
+ std::string name, description, usage, more;
- // returns text shown after the usage line
- //
- virtual std::string getMoreInfo() const;
+ Meta(
+ std::string name, std::string description,
+ std::string usage, std::string more);
+ };
// returns visible options specific to this command
//
@@ -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;