script: Added accept-eula command to commandline API and use in CI
This commit is contained in:
+2
-3
@@ -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"
|
||||
|
||||
@@ -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(
|
||||
|
||||
+24
-23
@@ -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<TextAccess> 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<TextAccess> 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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#include "utility/commandline/CommandLineParser.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <utility>
|
||||
|
||||
#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<commandline::CommandConfig>(this));
|
||||
addCommand(std::make_unique<commandline::CommandIndex>(this));
|
||||
|
||||
for ( auto& command : m_commands)
|
||||
addCommand(std::make_unique<commandline::CommandlineCommandConfig>(this));
|
||||
addCommand(std::make_unique<commandline::CommandlineCommandIndex>(this));
|
||||
addCommand(std::make_unique<commandline::CommandlineCommandAcceptEULA>(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> command)
|
||||
{
|
||||
m_commands.push_back(std::move(command));
|
||||
}
|
||||
|
||||
void CommandLineParser::preparse(int argc, char** argv)
|
||||
{
|
||||
// put argv into a string vector
|
||||
std::vector<std::string> args;
|
||||
for(int i = 1; i < argc; i++)
|
||||
{
|
||||
@@ -76,14 +67,16 @@ void CommandLineParser::preparse(std::vector<std::string>& 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<CommandlineCommand> 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;
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
#ifndef COMMANDLINEPARSER_H
|
||||
#define COMMANDLINEPARSER_H
|
||||
#ifndef COMMAND_LINE_PARSER_H
|
||||
#define COMMAND_LINE_PARSER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#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<std::string>& 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> command);
|
||||
void addCommand(std::unique_ptr<CommandlineCommand> command);
|
||||
void processProjectfile();
|
||||
void processLicense(const bool isLoaded);
|
||||
void printHelp() const;
|
||||
FilePath m_projectFile;
|
||||
|
||||
std::vector<std::shared_ptr<Command>> 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<std::shared_ptr<CommandlineCommand>> m_commands;
|
||||
std::vector<std::string> 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
|
||||
|
||||
@@ -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<FilePath> extractPaths(const std::vector<std::string>& vector);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,33 +2,44 @@
|
||||
#define COMMANDLINE_COMMAND_H
|
||||
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
|
||||
#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<std::string>& 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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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<std::string>& args)
|
||||
{
|
||||
return ReturnStatus::CMD_QUIT;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<std::string>& args);
|
||||
|
||||
virtual bool hasHelp() const { return false; }
|
||||
};
|
||||
|
||||
} // namespace commandline
|
||||
|
||||
#endif // COMMANDLINE_COMMAND_ACCEPT_EULA_H
|
||||
@@ -3,8 +3,6 @@
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
#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<FilePath>& 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<FilePath>& 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<std::string>& args)
|
||||
CommandlineCommand::ReturnStatus CommandlineCommandConfig::parse(std::vector<std::string>& args)
|
||||
{
|
||||
po::variables_map vm;
|
||||
try
|
||||
@@ -173,7 +160,17 @@ ReturnStatus CommandConfig::parse(std::vector<std::string>& 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +1,25 @@
|
||||
#ifndef COMMANDLINE_COMMAND_CONFIG_H
|
||||
#define COMMANDLINE_COMMAND_CONFIG_H
|
||||
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
#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<std::string>& args);
|
||||
|
||||
private:
|
||||
void printSettings(ApplicationSettings* settings);
|
||||
virtual bool hasHelp() const { return true; }
|
||||
};
|
||||
|
||||
} // namespace cmd
|
||||
} // namespace commandline
|
||||
|
||||
#endif // COMMANDLINE_COMMAND_CONFIG_H
|
||||
|
||||
@@ -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<std::string>& args)
|
||||
void CommandlineCommandIndex::preparse()
|
||||
{
|
||||
}
|
||||
|
||||
CommandlineCommand::ReturnStatus CommandlineCommandIndex::parse(std::vector<std::string>& args)
|
||||
{
|
||||
po::variables_map vm;
|
||||
try
|
||||
|
||||
@@ -1,27 +1,22 @@
|
||||
#ifndef COMMANDLINE_COMMAND_INDEX_H
|
||||
#define COMMANDLINE_COMMAND_INDEX_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#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<std::string>& args);
|
||||
|
||||
virtual bool hasHelp() const { return true; }
|
||||
};
|
||||
|
||||
} // namespace cmd
|
||||
|
||||
Reference in New Issue
Block a user