Debian Codegraph @

Source/Control/Interface/CommandLine/CHelpComandLinePreparationTranslator.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CHelpComandLinePreparationTranslator.h"
22
23
24 namespace Konclude {
25
26 namespace Control {
27
28 namespace Interface {
29
30 namespace CommandLine {
31
32
33 CHelpComandLinePreparationTranslator::CHelpComandLinePreparationTranslator(CLoaderFactory *loaderFactory) : CCommandLinePreparationTranslator(loaderFactory) {
34 mInterfaceTypeString = QString("CLI");
35 mMinNecessaryArguments = true;
36 mFirstArgumentTranslation = false;
37 }
38
39
40 CHelpComandLinePreparationTranslator::~CHelpComandLinePreparationTranslator() {
41 }
42
43
44 bool CHelpComandLinePreparationTranslator::translate(const QString& argumentText, QStringList& remainingArgList) {
45
46 bool argumentTranslated = false;
47
48
49 QString modArgText = argumentText.trimmed();
50 if (!mSkipTranslation) {
51 if (CCommandLinePreparationTranslator::translate(argumentText,remainingArgList)) {
52 argumentTranslated = true;
53 } else {
54 if (modArgText == "help" || modArgText == "?") {
55 mHelpRequested = true;
56 argumentTranslated = true;
57 mFirstArgumentTranslation = true;
58 }
59 }
60 }
61 return argumentTranslated;
62 }
63
64 bool CHelpComandLinePreparationTranslator::canTranslate(const QString& string) {
65 if (QString::compare(string,"help",Qt::CaseInsensitive) == 0 || QString::compare(string,"?",Qt::CaseInsensitive) == 0) {
66 return true;
67 }
68 return false;
69 }
70
71
72 QStringList CHelpComandLinePreparationTranslator::combineTranslatedArguments() {
73 QStringList translatedArgList;
74
75 if (!mFirstArgumentTranslation) {
76 mMinNecessaryArguments = false;
77 }
78
79 if (!mMinNecessaryArguments) {
80 LOG(ERROR,getLogDomain(),logTr("Execution with inadequate command line arguments."),this);
81 mHelpRequested = true;
82 }
83 return translatedArgList;
84 }
85
86
87
88
89
90 }; // end namespace CommandLine
91
92 }; // end namespace Interface
93
94 }; // end namespace Control
95
96 }; // end namespace Konclude