author | František Kučera <franta-hg@frantovo.cz> |
Sat, 02 Jul 2022 15:21:59 +0200 | |
branch | v_0 |
changeset 41 | e1339b8e838e |
parent 39 | f33464965693 |
child 42 | ca216de56ef0 |
permissions | -rw-r--r-- |
30
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* Relational pipes |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info) |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
*/ |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
#pragma once |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
#include <vector> |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
#include <iostream> |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
#include <relpipe/reader/typedefs.h> |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
#include <relpipe/cli/CLI.h> |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
#include <relpipe/cli/RelpipeCLIException.h> |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
#include "Configuration.h" |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
namespace relpipe { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
namespace out { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
namespace tabular { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
class CLIParser { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
private: |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
relpipe::reader::string_t readNext(const std::vector<relpipe::reader::string_t>& arguments, int& i) { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
if (i < arguments.size()) return arguments[i++]; |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
else throw relpipe::cli::RelpipeCLIException(L"Missing CLI argument" + (i > 0 ? (L" after " + arguments[i - 1]) : L""), relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
} |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
void addRelation(Configuration& c, RelationConfiguration& currentRelation) { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
if (currentRelation.relation.size()) { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
c.relationConfigurations.push_back(currentRelation); |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
} else { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
// no relation name given → global configuration |
31
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
45 |
c.writeTypes = currentRelation.writeTypes; |
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
46 |
c.writeRelationName = currentRelation.writeRelationName; |
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
47 |
c.writeRecordCount = currentRelation.writeRecordCount; |
30
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
} |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
currentRelation = RelationConfiguration(); |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
} |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
/** |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
* TODO: use a common method |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
*/ |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
bool parseBoolean(const relpipe::reader::string_t& value) { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
if (value == L"true") return true; |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
else if (value == L"false") return false; |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
else throw relpipe::cli::RelpipeCLIException(L"Unable to parse boolean value: " + value + L" (expecting true or false)", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
} |
38
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
60 |
|
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
61 |
Configuration::ColorScheme parseColorScheme(const relpipe::reader::string_t& value) { |
39
f33464965693
prepare for configurable color schemes
František Kučera <franta-hg@frantovo.cz>
parents:
38
diff
changeset
|
62 |
if (value == L"greenish") return Configuration::ColorScheme::Greenish; |
f33464965693
prepare for configurable color schemes
František Kučera <franta-hg@frantovo.cz>
parents:
38
diff
changeset
|
63 |
else if (value == L"amberish") return Configuration::ColorScheme::Amberish; |
41
e1339b8e838e
configurable color schemes: rename monochrome to black-and-white
František Kučera <franta-hg@frantovo.cz>
parents:
39
diff
changeset
|
64 |
else if (value == L"black-and-white") return Configuration::ColorScheme::BlackAndWhite; |
38
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
65 |
else if (value == L"midnight") return Configuration::ColorScheme::Midnight; |
41
e1339b8e838e
configurable color schemes: rename monochrome to black-and-white
František Kučera <franta-hg@frantovo.cz>
parents:
39
diff
changeset
|
66 |
else throw relpipe::cli::RelpipeCLIException(L"Unable to parse ColorScheme value: " + value + L" (expecting greenish, amberish, midnight or black-and-white)", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); |
38
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
67 |
} |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
68 |
|
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
69 |
Configuration::TableStyle parseTableStyle(const relpipe::reader::string_t& value) { |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
70 |
if (value == L"rounded") return Configuration::TableStyle::Rounded; |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
71 |
else if (value == L"sharp") return Configuration::TableStyle::Sharp; |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
72 |
else if (value == L"sharp-double") return Configuration::TableStyle::SharpDouble; |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
73 |
else if (value == L"horizontal-only") return Configuration::TableStyle::HorizontalOnly; |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
74 |
else if (value == L"ascii") return Configuration::TableStyle::Ascii; |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
75 |
else throw relpipe::cli::RelpipeCLIException(L"Unable to parse TableStyle value: " + value + L" (expecting rounded, sharp, ascii)", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
76 |
} |
30
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
77 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
78 |
public: |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
79 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
80 |
static const relpipe::reader::string_t OPTION_RELATION; |
31
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
81 |
static const relpipe::reader::string_t OPTION_WRITE_TYPES; |
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
82 |
static const relpipe::reader::string_t OPTION_WRITE_RELATION_NAME; |
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
83 |
static const relpipe::reader::string_t OPTION_WRITE_RECORD_COUNT; |
38
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
84 |
static const relpipe::reader::string_t OPTION_COLOR_SCHEME; |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
85 |
static const relpipe::reader::string_t OPTION_TABLE_STYLE; |
30
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
86 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
87 |
Configuration parse(const std::vector<relpipe::reader::string_t>& arguments) { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
88 |
Configuration c; |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
89 |
RelationConfiguration currentRelation; |
38
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
90 |
|
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
91 |
// TODO: global configuration of writeTypes, writeRelationName, writeRecordCount |
30
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
92 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
93 |
for (int i = 0; i < arguments.size();) { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
94 |
relpipe::reader::string_t option = readNext(arguments, i); |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
95 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
96 |
if (option == OPTION_RELATION) { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
97 |
addRelation(c, currentRelation); // previous relation |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
98 |
currentRelation.relation = readNext(arguments, i); |
31
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
99 |
} else if (option == OPTION_WRITE_TYPES) { |
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
100 |
currentRelation.writeTypes = parseBoolean(readNext(arguments, i)); |
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
101 |
} else if (option == OPTION_WRITE_RELATION_NAME) { |
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
102 |
currentRelation.writeRelationName = parseBoolean(readNext(arguments, i)); |
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
103 |
} else if (option == OPTION_WRITE_RECORD_COUNT) { |
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
104 |
currentRelation.writeRecordCount = parseBoolean(readNext(arguments, i)); |
38
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
105 |
} else if (option == OPTION_COLOR_SCHEME) { |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
106 |
c.colorScheme = parseColorScheme(readNext(arguments, i)); |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
107 |
} else if (option == OPTION_TABLE_STYLE) { |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
108 |
c.tableStyle = parseTableStyle(readNext(arguments, i)); |
30
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
109 |
} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
110 |
} |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
111 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
112 |
addRelation(c, currentRelation); // last relation |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
113 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
114 |
return c; |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
115 |
} |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
116 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
117 |
virtual ~CLIParser() { |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
118 |
} |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
119 |
}; |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
120 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
121 |
const relpipe::reader::string_t CLIParser::OPTION_RELATION = L"--relation"; |
31
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
122 |
const relpipe::reader::string_t CLIParser::OPTION_WRITE_TYPES = L"--write-types"; |
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
123 |
const relpipe::reader::string_t CLIParser::OPTION_WRITE_RELATION_NAME = L"--write-relation-name"; |
c22577615ce4
rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
30
diff
changeset
|
124 |
const relpipe::reader::string_t CLIParser::OPTION_WRITE_RECORD_COUNT = L"--write-record-count"; |
38
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
125 |
const relpipe::reader::string_t CLIParser::OPTION_COLOR_SCHEME = L"--color-scheme"; |
2cc2d3f658f4
configurable table style: rounded, sharp, sharp-double, horizontal-only, ascii
František Kučera <franta-hg@frantovo.cz>
parents:
31
diff
changeset
|
126 |
const relpipe::reader::string_t CLIParser::OPTION_TABLE_STYLE = L"--table-style"; |
30
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
127 |
|
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
128 |
} |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
129 |
} |
3c6374467a82
change CLI interface: options: --relation --print-types --print-relation-name --print-record-count
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
130 |
} |