mirror of
https://github.com/altlinux/admc.git
synced 2024-10-27 01:55:37 +03:00
remove Runner
This commit is contained in:
parent
560bb8fa7a
commit
0ef3c6e6b5
@ -48,7 +48,6 @@ set(ADMC_HEADER_DIRS
|
|||||||
set(ADMC_SOURCES
|
set(ADMC_SOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/admc.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/admc.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/Runner.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/ad_interface.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/ad_interface.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/details_widget.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/details_widget.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/attributes_widget.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/attributes_widget.cpp
|
||||||
|
@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* ADMC - AD Management Center
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 BaseALT Ltd.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "Runner.h"
|
|
||||||
#include "main_window.h"
|
|
||||||
#include "admc.h"
|
|
||||||
#include "ad_interface.h"
|
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
#include <QCommandLineParser>
|
|
||||||
#include <QCommandLineOption>
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
Runner::Runner(int& argc_, char **argv_, QString dispname, QString appname, QString appver, QString orgname, QString orgdomain) {
|
|
||||||
this->argc = argc_;
|
|
||||||
this->argv = argv_;
|
|
||||||
|
|
||||||
const auto admc = new ADMC(argc, argv);
|
|
||||||
this->app = admc;
|
|
||||||
this->app->setApplicationDisplayName(dispname);
|
|
||||||
this->app->setApplicationName(appname);
|
|
||||||
this->app->setApplicationVersion(appver);
|
|
||||||
this->app->setOrganizationName(orgname);
|
|
||||||
this->app->setOrganizationDomain(orgdomain);
|
|
||||||
|
|
||||||
// NOTE: have to load settings after org/app variables are set
|
|
||||||
// so that settings path is correct
|
|
||||||
admc->settings()->load_settings();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Runner::run() {
|
|
||||||
QCommandLineParser cli_parser;
|
|
||||||
cli_parser.setApplicationDescription(QCoreApplication::applicationName());
|
|
||||||
cli_parser.addHelpOption();
|
|
||||||
cli_parser.addVersionOption();
|
|
||||||
|
|
||||||
cli_parser.addOption({{"H", "host"}, "Host to use for login", "host"});
|
|
||||||
cli_parser.addOption({{"D", "domain"}, "Domain to use for login", "domain"});
|
|
||||||
|
|
||||||
const QStringList arg_list = qApp->arguments();
|
|
||||||
cli_parser.process(arg_list);
|
|
||||||
|
|
||||||
QStringList positional_args = cli_parser.positionalArguments();
|
|
||||||
if (positional_args.size() > 0) {
|
|
||||||
// CLI
|
|
||||||
const bool defined_login_values = cli_parser.isSet("host") && cli_parser.isSet("domain");
|
|
||||||
if (!defined_login_values) {
|
|
||||||
printf("Error: must define host and domain options, see help for options.");
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString host = cli_parser.value("host");
|
|
||||||
const QString domain = cli_parser.value("domain");
|
|
||||||
|
|
||||||
AD()->login(host, domain);
|
|
||||||
AD()->command(positional_args);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
// GUI
|
|
||||||
MainWindow main_window;
|
|
||||||
main_window.show();
|
|
||||||
|
|
||||||
return app->exec();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
39
src/Runner.h
39
src/Runner.h
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* ADMC - AD Management Center
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 BaseALT Ltd.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined(__ADMC_RUNNER_H)
|
|
||||||
#define __ADMC_RUNNER_H 1
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
class QApplication;
|
|
||||||
|
|
||||||
class Runner {
|
|
||||||
QApplication* app;
|
|
||||||
int argc;
|
|
||||||
char** argv;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Runner(int& argc, char **argv, QString dispname, QString appname, QString appver, QString orgname, QString orgdomain);
|
|
||||||
int run();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* __ADMC_RUNNER_H */
|
|
||||||
|
|
62
src/main.cpp
62
src/main.cpp
@ -18,18 +18,60 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "Runner.h"
|
#include "admc.h"
|
||||||
|
#include "main_window.h"
|
||||||
|
#include "ad_interface.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <QCommandLineParser>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
std::unique_ptr<Runner> runner(new Runner(argc,
|
const auto admc = new ADMC(argc, argv);
|
||||||
argv,
|
admc->setApplicationDisplayName(ADMC_APPLICATION_DISPLAY_NAME);
|
||||||
ADMC_APPLICATION_DISPLAY_NAME,
|
admc->setApplicationName(ADMC_APPLICATION_NAME);
|
||||||
ADMC_APPLICATION_NAME,
|
admc->setApplicationVersion(ADMC_VERSION);
|
||||||
ADMC_VERSION,
|
admc->setOrganizationName(ADMC_ORGANIZATION);
|
||||||
ADMC_ORGANIZATION,
|
admc->setOrganizationDomain(ADMC_ORGANIZATION_DOMAIN);
|
||||||
ADMC_ORGANIZATION_DOMAIN));
|
// NOTE: must load settings after setting app/org names so that
|
||||||
|
// settings file path is correct
|
||||||
|
admc->settings()->load_settings();
|
||||||
|
|
||||||
return runner->run();
|
QCommandLineParser cli_parser;
|
||||||
|
cli_parser.setApplicationDescription(QCoreApplication::applicationName());
|
||||||
|
cli_parser.addHelpOption();
|
||||||
|
cli_parser.addVersionOption();
|
||||||
|
|
||||||
|
cli_parser.addOption({{"H", "host"}, "Host to use for login", "host"});
|
||||||
|
cli_parser.addOption({{"D", "domain"}, "Domain to use for login", "domain"});
|
||||||
|
|
||||||
|
const QStringList arg_list = qApp->arguments();
|
||||||
|
cli_parser.process(arg_list);
|
||||||
|
|
||||||
|
QStringList positional_args = cli_parser.positionalArguments();
|
||||||
|
if (positional_args.size() > 0) {
|
||||||
|
// CLI
|
||||||
|
const bool defined_login_values = cli_parser.isSet("host") && cli_parser.isSet("domain");
|
||||||
|
if (!defined_login_values) {
|
||||||
|
printf("Error: must define host and domain options, see help for options.");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString host = cli_parser.value("host");
|
||||||
|
const QString domain = cli_parser.value("domain");
|
||||||
|
|
||||||
|
AD()->login(host, domain);
|
||||||
|
AD()->command(positional_args);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
// GUI
|
||||||
|
MainWindow main_window;
|
||||||
|
main_window.show();
|
||||||
|
|
||||||
|
const int retval = admc->exec();
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user