-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
200 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include "CLI.h" | ||
#include "CLIResult.h" | ||
#include "ConfigTS.h" | ||
//#include "TSXformTypeString.h" | ||
#include <Util/CoutBuf.hpp> | ||
|
||
#include <EnjoLibBoost/ProgramOptions.hpp> | ||
|
||
using namespace EnjoLib; | ||
|
||
CLI::CLI(){} | ||
CLI::~CLI(){} | ||
|
||
EnjoLib::Result<CLIResult> CLI::GetConfigs(int argc, char ** argv) const | ||
{ | ||
//const char * OPT_PLUGIN = "plugin"; | ||
|
||
const char * OPT_MIN_MONTH = "min-month"; | ||
const char * OPT_MIN_YEAR = "min-year"; | ||
const char * OPT_MAX_MONTH = "max-month"; | ||
const char * OPT_MAX_YEAR = "max-year"; | ||
//const char * OPT_LATEST_DATE = "latest-date"; | ||
const char * OPT_SYMBOL = "sym"; | ||
const char * OPT_PERIOD = "per"; | ||
|
||
EnjoLib::ProgramOptionsState popState; | ||
////popState.AddStr(OPT_PLUGIN, "Plugin name"); | ||
popState.AddInt(OPT_MIN_MONTH, "Start month"); /// TODO: Option Add(char*, char*, int & refVal);. A new class beside the old one or replace the old one? | ||
popState.AddInt(OPT_MIN_YEAR, "Start year"); | ||
popState.AddInt(OPT_MAX_MONTH, "End month"); | ||
popState.AddInt(OPT_MAX_YEAR, "End year"); | ||
popState.AddStr(OPT_SYMBOL, "Symbol name"); | ||
popState.AddStr(OPT_PERIOD, "Period name"); | ||
|
||
popState.ReadArgs(argc, argv); | ||
const EnjoLib::ProgramOptions pops(popState); | ||
|
||
ConfigSym confSym; | ||
|
||
if (pops.IsHelpRequested()) | ||
{ | ||
/// TODO: Try also to react also on -h by adding here: | ||
/** | ||
bool ProgramOptions::IsHelpRequested() const | ||
{ | ||
return GetBoolFromMap(ProgramOptionsState::OPT_HELP); | ||
} | ||
return GetBoolFromMap(ProgramOptionsState::OPT_HELP || return GetBoolFromMap(ProgramOptionsState::OPT_HELP_MIN);); | ||
const char * OPT_HELP_MIN = "h"; | ||
*/ | ||
ELO | ||
LOG << pops.GetHelp() << Nl; | ||
|
||
LOG << GetAdditionalHelp(); | ||
LOG << Nl; | ||
LOG << "The default path of the script is: " << ConfigTS::DEFAULT_SCRIPT_FILE_NAME << Nl; | ||
LOG << "\n(C) 2012-2022 mj-xmr. Licensed under AGPLv3.\n"; | ||
LOG << "https://github.com/mj-xmr/tsqsim\n"; | ||
LOG << "\nRemember to be happy.\n\n"; | ||
return EnjoLib::Result<CLIResult>(CLIResult(confSym), false); | ||
} | ||
|
||
confSym.dates.Set0(); | ||
|
||
confSym.dates.monthStart = pops.GetIntFromMap(OPT_MIN_MONTH); | ||
confSym.dates.yearStart = pops.GetIntFromMap(OPT_MIN_YEAR); | ||
confSym.dates.monthEnd = pops.GetIntFromMap(OPT_MAX_MONTH); | ||
confSym.dates.yearEnd = pops.GetIntFromMap(OPT_MAX_YEAR); | ||
confSym.symbol = pops.GetStrFromMap(OPT_SYMBOL); | ||
confSym.period = pops.GetStrFromMap(OPT_PERIOD); | ||
|
||
//auto pluginName = pops.GetStrFromMap (OPT_PLUGIN); | ||
|
||
CLIResult res(confSym); | ||
|
||
return EnjoLib::Result<CLIResult>(CLIResult(confSym), true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef CLI_H | ||
#define CLI_H | ||
|
||
#include <Util/Str.hpp> | ||
#include <Util/Result.hpp> | ||
|
||
struct CLIResult; | ||
|
||
class CLI | ||
{ | ||
public: | ||
CLI(); | ||
virtual ~CLI(); | ||
|
||
EnjoLib::Result<CLIResult> GetConfigs(int argc, char ** argv) const; | ||
|
||
virtual EnjoLib::Str GetAdditionalHelp() const = 0; | ||
|
||
protected: | ||
|
||
private: | ||
}; | ||
|
||
#endif // CLI_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "CLIResult.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef CLIRESULT_H | ||
#define CLIRESULT_H | ||
|
||
#include "ConfigSym.h" | ||
|
||
struct CLIResult | ||
{ | ||
CLIResult(const ConfigSym & confSym) | ||
: m_confSym(confSym) | ||
{ | ||
|
||
} | ||
|
||
ConfigSym m_confSym; | ||
|
||
}; | ||
|
||
#endif // CLIRESULT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "CLITsq.h" | ||
#include "TSXformTypeString.h" | ||
|
||
#include <Ios/Osstream.hpp> | ||
#include <Template/Array.hpp> | ||
|
||
using namespace EnjoLib; | ||
|
||
CLITsq::CLITsq(){} | ||
CLITsq::~CLITsq(){} | ||
|
||
EnjoLib::Str CLITsq::GetAdditionalHelp() const | ||
{ | ||
Osstream oss; | ||
const TSXformTypeString types; | ||
oss << "Available transformations for text-based scripting:\n"; | ||
for (const Str & name : types.GetNames()) | ||
{ | ||
oss << name << " "; | ||
} | ||
|
||
return oss.str(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef CLITSQ_H | ||
#define CLITSQ_H | ||
|
||
#include "CLI.h" | ||
|
||
#include <Util/Str.hpp> | ||
#include <Util/Result.hpp> | ||
|
||
struct CLIResult; | ||
|
||
class CLITsq : public CLI | ||
{ | ||
public: | ||
CLITsq(); | ||
virtual ~CLITsq(); | ||
|
||
EnjoLib::Str GetAdditionalHelp() const override; | ||
|
||
protected: | ||
|
||
private: | ||
}; | ||
|
||
#endif // CLITSQ_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters