diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e91a3830..02266afd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,8 +15,7 @@ variables: script: - ./script/buildonly.sh all - ./script/buildonly.sh package - - ./build/Release/app/Sourcetrail config -z ./setup/license.txt - - ./script/build.sh r test + - ./script/build.sh release test artifacts: name: "$CI_JOB_NAME" paths: @@ -74,7 +73,7 @@ LicenseGenerator: when: manual script: - ./script/setup.sh - - ./script/buildonly.sh r keygen + - ./script/buildonly.sh release keygen - mv build/Release/license_generator/Sourcetrail_license_generator . artifacts: name: "$CI_JOB_NAME" diff --git a/cmake/pre_install_linux.cmake b/cmake/pre_install_linux.cmake index f6fb21ac..43182f44 100644 --- a/cmake/pre_install_linux.cmake +++ b/cmake/pre_install_linux.cmake @@ -15,7 +15,7 @@ set(binPath ${CMAKE_CURRENT_LIST_DIR}/../build/Release/app/Sourcetrail) set(projPath ${CMAKE_CURRENT_LIST_DIR}/../bin/app/user/projects) execute_process( - COMMAND ${binPath} config -z ${CMAKE_CURRENT_LIST_DIR}/../setup/license.txt + COMMAND ${binPath} accept-eula ) execute_process( diff --git a/src/app/main.cpp b/src/app/main.cpp index 9bb58cf0..3a6b1dcf 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -215,7 +215,7 @@ int main(int argc, char *argv[]) L"version " + version.toDisplayWString() ).dispatch(); - commandline::CommandLineParser commandLineParser(version.toString()); + commandline::CommandLineParser commandLineParser(version.toDisplayString()); commandLineParser.preparse(argc, argv); if (commandLineParser.exitApplication()) { @@ -242,29 +242,30 @@ int main(int argc, char *argv[]) ApplicationSettings* appSettings = ApplicationSettings::getInstance().get(); if (appSettings->getAcceptedEulaVersion() < QtEulaWindow::EULA_VERSION) { - // to avoid interferring with other console output - std::this_thread::sleep_for(std::chrono::milliseconds(250)); - - std::shared_ptr text = - TextAccess::createFromFile(ResourcePaths::getGuiPath().concatenate(L"installer/EULA.txt")); - - std::cout << std::endl << text->getText() << std::endl; - std::cout << "Do you accept the Sourcetrail Software License Agreement? (y/n)" << std::endl; - - char c = 'n'; - std::cin >> c; - - if (c == 'Y' || c == 'y') + if (!commandLineParser.acceptedEULA()) { - std::cout << "\nAgreement accepted.\n" << std::endl; - appSettings->setAcceptedEulaVersion(QtEulaWindow::EULA_VERSION); - appSettings->save(); - } - else - { - std::cout << "\nAgreement not accepted. quitting..." << std::endl; - return 1; + // to avoid interferring with other console output + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + + std::shared_ptr text = + TextAccess::createFromFile(ResourcePaths::getGuiPath().concatenate(L"installer/EULA.txt")); + + std::cout << std::endl << text->getText() << std::endl; + std::cout << "Do you accept the Sourcetrail End User License Agreement? (y/n)" << std::endl; + + char c = 'n'; + std::cin >> c; + + if (c != 'Y' && c != 'y') + { + std::cout << "\nAgreement not accepted. quitting..." << std::endl; + return 1; + } } + + std::cout << "\nSourcetrail End User License Agreement accepted.\n" << std::endl; + appSettings->setAcceptedEulaVersion(QtEulaWindow::EULA_VERSION); + appSettings->save(); } prefillPaths(); @@ -281,7 +282,7 @@ int main(int argc, char *argv[]) return 0; } - if (commandLineParser.hasError() ) + if (commandLineParser.hasError()) { std::wcout << commandLineParser.getError() << std::endl; } diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 64cbc2e3..fd1eaac4 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -339,6 +339,8 @@ add_files( utility/commandline/CommandLineParser.h utility/commandline/commands/CommandlineCommand.cpp utility/commandline/commands/CommandlineCommand.h + utility/commandline/commands/CommandlineCommandAcceptEULA.cpp + utility/commandline/commands/CommandlineCommandAcceptEULA.h utility/commandline/commands/CommandlineCommandConfig.cpp utility/commandline/commands/CommandlineCommandConfig.h utility/commandline/commands/CommandlineCommandIndex.cpp diff --git a/src/lib/utility/commandline/CommandLineParser.cpp b/src/lib/utility/commandline/CommandLineParser.cpp index a0434bc5..fe906b50 100644 --- a/src/lib/utility/commandline/CommandLineParser.cpp +++ b/src/lib/utility/commandline/CommandLineParser.cpp @@ -1,19 +1,17 @@ #include "utility/commandline/CommandLineParser.h" #include -#include #include #include "boost/program_options.hpp" #include "utility/commandline/CommandlineHelper.h" +#include "utility/commandline/commands/CommandlineCommandAcceptEULA.h" #include "utility/commandline/commands/CommandlineCommandConfig.h" #include "utility/commandline/commands/CommandlineCommandIndex.h" #include "utility/ConfigManager.h" #include "utility/text/TextAccess.h" #include "utility/utilityString.h" -#include "License.h" -#include "PublicKey.h" namespace po = boost::program_options; @@ -26,9 +24,13 @@ CommandLineParser::CommandLineParser(const std::string& version) setup(); } +CommandLineParser::~CommandLineParser() +{ +} + void CommandLineParser::setup() { - po::options_description options("Sourcetrail Options"); + po::options_description options("Options"); options.add_options() ("help,h", "Print this help message") ("version,v", "Version of Sourcetrail") @@ -37,30 +39,19 @@ void CommandLineParser::setup() m_options.add(options); m_positional.add("project-file", 1); - addCommand(std::make_unique(this)); - addCommand(std::make_unique(this)); - for ( auto& command : m_commands) + addCommand(std::make_unique(this)); + addCommand(std::make_unique(this)); + addCommand(std::make_unique(this)); + + for (auto& command : m_commands) { command->setup(); } - -} - -void CommandLineParser::setProjectFile(const FilePath &filepath) -{ - m_projectFile = filepath; - processProjectfile(); -} - -void CommandLineParser::addCommand(std::unique_ptr command) -{ - m_commands.push_back(std::move(command)); } void CommandLineParser::preparse(int argc, char** argv) { - // put argv into a string vector std::vector args; for(int i = 1; i < argc; i++) { @@ -76,14 +67,16 @@ void CommandLineParser::preparse(std::vector& args) { return; } - m_args = std::move(args); + + m_args = args; + try { - // parsing for all commands - for ( auto& command : m_commands) + for (auto& command : m_commands) { if ( m_args[0] == command->name()) { + command->preparse(); m_withoutGUI = true; return; } @@ -127,34 +120,40 @@ void CommandLineParser::parse() { return; } + try { // parsing for all commands - for ( auto& command : m_commands) + for (auto& command : m_commands) { if ( m_args[0] == command->name()) { m_args.erase(m_args.begin()); - ReturnStatus status = command->parse(m_args); - if (status == ReturnStatus::CMD_QUIT - || status == ReturnStatus::CMD_FAILURE) + CommandlineCommand::ReturnStatus status = command->parse(m_args); + + if (status != CommandlineCommand::ReturnStatus::CMD_OK) { m_quit = true; } } } } - catch(boost::program_options::error& e) + catch (boost::program_options::error& e) { std::cerr << "ERROR: " << e.what() << std::endl << std::endl; std::cerr << m_options << std::endl; } - } -License* CommandLineParser::getLicensePtr() +void CommandLineParser::setProjectFile(const FilePath &filepath) { - return &m_license; + m_projectFile = filepath; + processProjectfile(); +} + +void CommandLineParser::addCommand(std::unique_ptr command) +{ + m_commands.push_back(std::move(command)); } void CommandLineParser::printHelp() const @@ -163,11 +162,13 @@ void CommandLineParser::printHelp() const // Commands std::cout << "Commands:\n"; - for (auto& Command : m_commands) + for (auto& command : m_commands) { - std::cout << " " << Command->name() << "\n"; + std::cout << " " << command->name(); + std::cout << std::string(std::max(23 - command->name().size(), size_t(2)), ' '); + std::cout << command->description() << (command->hasHelp() ? "*" : "") << "\n"; } - std::cout << "\n * Each command has its own --help\n"; + std::cout << "\n * has its own --help\n"; std::cout << m_options << std::endl; @@ -176,14 +177,28 @@ void CommandLineParser::printHelp() const std::cout << "Positional Arguments: "; for (unsigned int i = 0; i < m_positional.max_total_count(); i++) { - std::cout << "\n " << i+1 << ": " << m_positional.name_for_position(i); + std::cout << "\n " << i + 1 << ": " << m_positional.name_for_position(i); } std::cout << std::endl; } } +bool CommandLineParser::runWithoutGUI() const +{ + return m_withoutGUI; +} -bool CommandLineParser::hasError() +bool CommandLineParser::exitApplication() const +{ + return m_quit; +} + +bool CommandLineParser::acceptedEULA() const +{ + return m_acceptEULA; +} + +bool CommandLineParser::hasError() const { return !m_errorString.empty(); } @@ -193,29 +208,6 @@ std::wstring CommandLineParser::getError() return m_errorString; } -CommandLineParser::~CommandLineParser() -{ -} - -bool CommandLineParser::runWithoutGUI() -{ - return m_withoutGUI; -} - -bool CommandLineParser::exitApplication() -{ - return m_quit; -} - -bool CommandLineParser::startedWithLicense() -{ - if (m_license.getUser().empty()) - { - return false; - } - return m_license.isValid(); -} - void CommandLineParser::processProjectfile() { m_projectFile.makeAbsolute(); @@ -245,11 +237,6 @@ void CommandLineParser::processProjectfile() } } -License CommandLineParser::getLicense() -{ - return m_license; -} - void CommandLineParser::fullRefresh() { m_refreshMode = REFRESH_ALL_FILES; @@ -260,6 +247,11 @@ void CommandLineParser::incompleteRefresh() m_refreshMode = REFRESH_UPDATED_AND_INCOMPLETE_FILES; } +void CommandLineParser::acceptEULA() +{ + m_acceptEULA = true; +} + const FilePath& CommandLineParser::getProjectFilePath() const { return m_projectFile; diff --git a/src/lib/utility/commandline/CommandLineParser.h b/src/lib/utility/commandline/CommandLineParser.h index 6de968a4..dbd44cc5 100644 --- a/src/lib/utility/commandline/CommandLineParser.h +++ b/src/lib/utility/commandline/CommandLineParser.h @@ -1,14 +1,12 @@ -#ifndef COMMANDLINEPARSER_H -#define COMMANDLINEPARSER_H +#ifndef COMMAND_LINE_PARSER_H +#define COMMAND_LINE_PARSER_H -#include #include #include #include #include "boost/program_options.hpp" -#include "License.h" #include "project/RefreshInfo.h" #include "utility/file/FilePath.h" @@ -16,62 +14,58 @@ namespace po = boost::program_options; namespace commandline { -class Command; +class CommandlineCommand; class CommandLineParser { public: - CommandLineParser(const std::string& version); ~CommandLineParser(); void setup(); void preparse(int argc, char** argv); - - /// args will be moved so dont use them after calling this function void preparse(std::vector& args); void parse(); - bool runWithoutGUI(); - bool exitApplication(); - bool startedWithLicense(); - bool hasError(); + bool runWithoutGUI() const; + bool exitApplication() const; + bool acceptedEULA() const; + bool hasError() const; + std::wstring getError(); + + void acceptEULA(); void fullRefresh(); void incompleteRefresh(); - std::wstring getError(); - License getLicense(); - License* getLicensePtr(); - const FilePath& getProjectFilePath() const; void setProjectFile(const FilePath& filepath); + RefreshMode getRefreshMode() const; private: - void addCommand(std::unique_ptr command); + void addCommand(std::unique_ptr command); void processProjectfile(); - void processLicense(const bool isLoaded); void printHelp() const; - FilePath m_projectFile; - - std::vector> m_commands; - - const std::string m_version; - RefreshMode m_refreshMode = REFRESH_UPDATED_FILES; - bool m_quit{false}; - bool m_withoutGUI{false}; boost::program_options::options_description m_options; boost::program_options::positional_options_description m_positional; - std::wstring m_errorString; - License m_license; - + std::vector> m_commands; std::vector m_args; + + const std::string m_version; + FilePath m_projectFile; + RefreshMode m_refreshMode = REFRESH_UPDATED_FILES; + + bool m_quit = false; + bool m_withoutGUI = false; + bool m_acceptEULA = false; + + std::wstring m_errorString; }; -} // namespace cmd +} // namespace commmandline -#endif //COMMANDLINEPARSER_H +#endif // COMMAND_LINE_PARSER_H diff --git a/src/lib/utility/commandline/CommandlineHelper.h b/src/lib/utility/commandline/CommandlineHelper.h index 6b2ee65a..ca3123d5 100644 --- a/src/lib/utility/commandline/CommandlineHelper.h +++ b/src/lib/utility/commandline/CommandlineHelper.h @@ -18,12 +18,6 @@ namespace po = boost::program_options; namespace commandline { - enum class ReturnStatus { - CMD_OK, - CMD_QUIT, - CMD_FAILURE - }; - void parseConfigFile(po::variables_map& vm, po::options_description& options); std::vector extractPaths(const std::vector& vector); diff --git a/src/lib/utility/commandline/commands/CommandlineCommand.cpp b/src/lib/utility/commandline/commands/CommandlineCommand.cpp index 3a085c15..4e1cc1d2 100644 --- a/src/lib/utility/commandline/commands/CommandlineCommand.cpp +++ b/src/lib/utility/commandline/commands/CommandlineCommand.cpp @@ -5,26 +5,33 @@ namespace commandline { -Command::Command(const std::string name, CommandLineParser* parser) +CommandlineCommand::CommandlineCommand(const std::string& name, const std::string& description, CommandLineParser* parser) : m_name(name) + , m_description(description) , m_parser(parser) { } -Command::~Command() +CommandlineCommand::~CommandlineCommand() { } -const std::string Command::name() +const std::string& CommandlineCommand::name() { return m_name; } -void Command::printHelp() +const std::string& CommandlineCommand::description() { - std::cout << "Usage:\n Sourcetrail " - << m_name << " [option...]\n\n"; + return m_description; +} + +void CommandlineCommand::printHelp() +{ + std::cout << "Usage:\n\n Sourcetrail " << m_name << " [option...]\n\n"; + std::cout << m_description << "\n\n"; std::cout << m_options << std::endl; + if (m_positional.max_total_count() > 0) { std::cout << "Positional Arguments: "; @@ -36,4 +43,4 @@ void Command::printHelp() } } -} // namespace cmd +} // namespace commandline diff --git a/src/lib/utility/commandline/commands/CommandlineCommand.h b/src/lib/utility/commandline/commands/CommandlineCommand.h index 5a92a649..849e983c 100644 --- a/src/lib/utility/commandline/commands/CommandlineCommand.h +++ b/src/lib/utility/commandline/commands/CommandlineCommand.h @@ -2,33 +2,44 @@ #define COMMANDLINE_COMMAND_H #include -#include + #include "boost/program_options.hpp" namespace po = boost::program_options; namespace commandline { -enum class ReturnStatus; class CommandLineParser; -class Command +class CommandlineCommand { public: - Command(const std::string name, CommandLineParser* parser = nullptr); - virtual ~Command(); + enum class ReturnStatus { + CMD_OK, + CMD_QUIT, + CMD_FAILURE + }; - const std::string name(); + CommandlineCommand(const std::string& name, const std::string& description, CommandLineParser* parser); + virtual ~CommandlineCommand(); + + const std::string& name(); + const std::string& description(); virtual void setup() = 0; + virtual void preparse() = 0; virtual ReturnStatus parse(std::vector& args) = 0; + + virtual bool hasHelp() const = 0; virtual void printHelp(); protected: const std::string m_name; + const std::string m_description; + CommandLineParser* m_parser; + po::options_description m_options; po::positional_options_description m_positional; - CommandLineParser* m_parser; }; } diff --git a/src/lib/utility/commandline/commands/CommandlineCommandAcceptEULA.cpp b/src/lib/utility/commandline/commands/CommandlineCommandAcceptEULA.cpp new file mode 100644 index 00000000..bc4a042e --- /dev/null +++ b/src/lib/utility/commandline/commands/CommandlineCommandAcceptEULA.cpp @@ -0,0 +1,32 @@ +#include "utility/commandline/commands/CommandlineCommandAcceptEULA.h" + +#include "utility/commandline/CommandlineHelper.h" +#include "utility/commandline/CommandLineParser.h" + +namespace commandline +{ + +CommandlineCommandAcceptEULA::CommandlineCommandAcceptEULA(CommandLineParser* parser) + : CommandlineCommand("accept-eula", "Accept the Sourcetrail End User License Agreement.", parser) +{ +} + +CommandlineCommandAcceptEULA::~CommandlineCommandAcceptEULA() +{ +} + +void CommandlineCommandAcceptEULA::setup() +{ +} + +void CommandlineCommandAcceptEULA::preparse() +{ + m_parser->acceptEULA(); +} + +CommandlineCommand::ReturnStatus CommandlineCommandAcceptEULA::parse(std::vector& args) +{ + return ReturnStatus::CMD_QUIT; +} + +} diff --git a/src/lib/utility/commandline/commands/CommandlineCommandAcceptEULA.h b/src/lib/utility/commandline/commands/CommandlineCommandAcceptEULA.h new file mode 100644 index 00000000..2ec08c15 --- /dev/null +++ b/src/lib/utility/commandline/commands/CommandlineCommandAcceptEULA.h @@ -0,0 +1,27 @@ +#ifndef COMMANDLINE_COMMAND_ACCEPT_EULA_H +#define COMMANDLINE_COMMAND_ACCEPT_EULA_H + +#include "utility/commandline/commands/CommandlineCommand.h" + +class CommandLineParser; + +namespace commandline +{ + +class CommandlineCommandAcceptEULA + : public CommandlineCommand +{ +public: + CommandlineCommandAcceptEULA(CommandLineParser* parser); + virtual ~CommandlineCommandAcceptEULA(); + + virtual void setup(); + virtual void preparse(); + virtual ReturnStatus parse(std::vector& args); + + virtual bool hasHelp() const { return false; } +}; + +} // namespace commandline + +#endif // COMMANDLINE_COMMAND_ACCEPT_EULA_H diff --git a/src/lib/utility/commandline/commands/CommandlineCommandConfig.cpp b/src/lib/utility/commandline/commands/CommandlineCommandConfig.cpp index 081f397d..559f3013 100644 --- a/src/lib/utility/commandline/commands/CommandlineCommandConfig.cpp +++ b/src/lib/utility/commandline/commands/CommandlineCommandConfig.cpp @@ -3,8 +3,6 @@ #include #include -#include "boost/program_options.hpp" - #include "utility/commandline/CommandlineHelper.h" #include "utility/commandline/CommandLineParser.h" #include "utility/file/FilePath.h" @@ -73,16 +71,30 @@ void parseAndSetValue( } } -CommandConfig::CommandConfig(CommandLineParser* parser) - : Command("config", parser) +void printVector(const std::string& title, const std::vector& vec) +{ + std::cout << "\n " << title << ":"; + if (vec.empty()) + { + std::cout << "\n -\n"; + } + for (const FilePath& item : vec) + { + std::cout << "\n " << item.str(); + } +} + + +CommandlineCommandConfig::CommandlineCommandConfig(CommandLineParser* parser) + : CommandlineCommand("config", "Change preferences relevant to project indexing.", parser) { } -CommandConfig::~CommandConfig() +CommandlineCommandConfig::~CommandlineCommandConfig() { } -void CommandConfig::setup() +void CommandlineCommandConfig::setup() { po::options_description options("Config Options"); options.add_options() @@ -110,36 +122,11 @@ void CommandConfig::setup() m_options.add(options); } -void printVector(const std::string& title, const std::vector& vec) +void CommandlineCommandConfig::preparse() { - std::cout << "\n " << title << ":"; - if (vec.empty()) - { - std::cout << "\n -\n"; - } - for (const FilePath& item : vec) - { - std::cout << "\n " << item.str(); - } } -void CommandConfig::printSettings(ApplicationSettings* settings) -{ - std::cout << "Sourcetrail Settings:\n" - << "\n indexer-threads: " << settings->getIndexerThreadCount() - << "\n use-processes: " << settings->getMultiProcessIndexingEnabled() - << "\n logging-enabled: " << settings->getLoggingEnabled() - << "\n verbose-indexer-logging-enabled: " << settings->getVerboseIndexerLoggingEnabled() - << "\n jvm-path: " << settings->getJavaPath().str() - << "\n jvm-max-memory: " << settings->getJavaMaximumMemory() - << "\n maven-path: " << settings->getMavenPath().str(); - printVector("global-header-search-paths", settings->getHeaderSearchPaths()); - printVector("global-framework-search-paths", settings->getFrameworkSearchPaths()); - printVector("jre-system-library-paths", settings->getJreSystemLibraryPaths()); -} - - -ReturnStatus CommandConfig::parse(std::vector& args) +CommandlineCommand::ReturnStatus CommandlineCommandConfig::parse(std::vector& args) { po::variables_map vm; try @@ -173,7 +160,17 @@ ReturnStatus CommandConfig::parse(std::vector& args) if (args[0] == "show" || vm.count("show")) { - printSettings(settings); + std::cout << "Sourcetrail Settings:\n" + << "\n indexer-threads: " << settings->getIndexerThreadCount() + << "\n use-processes: " << settings->getMultiProcessIndexingEnabled() + << "\n logging-enabled: " << settings->getLoggingEnabled() + << "\n verbose-indexer-logging-enabled: " << settings->getVerboseIndexerLoggingEnabled() + << "\n jvm-path: " << settings->getJavaPath().str() + << "\n jvm-max-memory: " << settings->getJavaMaximumMemory() + << "\n maven-path: " << settings->getMavenPath().str(); + printVector("global-header-search-paths", settings->getHeaderSearchPaths()); + printVector("global-framework-search-paths", settings->getFrameworkSearchPaths()); + printVector("jre-system-library-paths", settings->getJreSystemLibraryPaths()); return ReturnStatus::CMD_QUIT; } diff --git a/src/lib/utility/commandline/commands/CommandlineCommandConfig.h b/src/lib/utility/commandline/commands/CommandlineCommandConfig.h index cc3e4648..85be0492 100644 --- a/src/lib/utility/commandline/commands/CommandlineCommandConfig.h +++ b/src/lib/utility/commandline/commands/CommandlineCommandConfig.h @@ -1,31 +1,25 @@ #ifndef COMMANDLINE_COMMAND_CONFIG_H #define COMMANDLINE_COMMAND_CONFIG_H -#include -#include #include "utility/commandline/commands/CommandlineCommand.h" -class ApplicationSettings; -class CommandLineParser; - namespace commandline { -enum class ReturnStatus; -class CommandConfig - : public Command +class CommandlineCommandConfig + : public CommandlineCommand { public: - CommandConfig(CommandLineParser* parser); - virtual ~CommandConfig(); + CommandlineCommandConfig(CommandLineParser* parser); + virtual ~CommandlineCommandConfig(); virtual void setup(); + virtual void preparse(); virtual ReturnStatus parse(std::vector& args); -private: - void printSettings(ApplicationSettings* settings); + virtual bool hasHelp() const { return true; } }; -} // namespace cmd +} // namespace commandline #endif // COMMANDLINE_COMMAND_CONFIG_H diff --git a/src/lib/utility/commandline/commands/CommandlineCommandIndex.cpp b/src/lib/utility/commandline/commands/CommandlineCommandIndex.cpp index 3506bcd0..ab6fe138 100644 --- a/src/lib/utility/commandline/commands/CommandlineCommandIndex.cpp +++ b/src/lib/utility/commandline/commands/CommandlineCommandIndex.cpp @@ -3,19 +3,21 @@ #include "utility/commandline/CommandlineHelper.h" #include "utility/commandline/CommandLineParser.h" +namespace po = boost::program_options; + namespace commandline { -CommandIndex::CommandIndex(CommandLineParser* parser) - : Command("index", parser) +CommandlineCommandIndex::CommandlineCommandIndex(CommandLineParser* parser) + : CommandlineCommand("index", "Index a certain project.", parser) { } -CommandIndex::~CommandIndex() +CommandlineCommandIndex::~CommandlineCommandIndex() { } -void CommandIndex::setup() +void CommandlineCommandIndex::setup() { po::options_description options("Config Options"); options.add_options() @@ -29,7 +31,11 @@ void CommandIndex::setup() m_positional.add("project-file", 1); } -ReturnStatus CommandIndex::parse(std::vector& args) +void CommandlineCommandIndex::preparse() +{ +} + +CommandlineCommand::ReturnStatus CommandlineCommandIndex::parse(std::vector& args) { po::variables_map vm; try diff --git a/src/lib/utility/commandline/commands/CommandlineCommandIndex.h b/src/lib/utility/commandline/commands/CommandlineCommandIndex.h index cb5d5462..987a1854 100644 --- a/src/lib/utility/commandline/commands/CommandlineCommandIndex.h +++ b/src/lib/utility/commandline/commands/CommandlineCommandIndex.h @@ -1,27 +1,22 @@ #ifndef COMMANDLINE_COMMAND_INDEX_H #define COMMANDLINE_COMMAND_INDEX_H -#include - -#include "boost/program_options.hpp" - #include "utility/commandline/commands/CommandlineCommand.h" -namespace po = boost::program_options; - namespace commandline { -enum class ReturnStatus; - -class CommandIndex - : public Command +class CommandlineCommandIndex + : public CommandlineCommand { public: - CommandIndex(CommandLineParser* parser); - virtual ~CommandIndex(); + CommandlineCommandIndex(CommandLineParser* parser); + virtual ~CommandlineCommandIndex(); virtual void setup(); + virtual void preparse(); virtual ReturnStatus parse(std::vector& args); + + virtual bool hasHelp() const { return true; } }; } // namespace cmd