[osmium-tool] 39/44: Extract handling of input options in common function.
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Tue Jul 21 20:15:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to tag v1.1.0
in repository osmium-tool.
commit 7c5cdb282be4a9109be1920f77dbe272432f47e9
Author: Jochen Topf <jochen at topf.org>
Date: Fri Jul 3 14:56:51 2015 +0200
Extract handling of input options in common function.
---
src/command_apply_changes.cpp | 2 +-
src/command_cat.cpp | 2 +-
src/command_check_refs.cpp | 5 ++---
src/command_fileinfo.cpp | 7 ++++---
src/command_getid.cpp | 4 +---
src/command_merge_changes.cpp | 2 +-
src/command_renumber.cpp | 2 +-
src/command_time_filter.cpp | 4 +---
src/osmc.hpp | 12 ++++++++++++
9 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/src/command_apply_changes.cpp b/src/command_apply_changes.cpp
index 5a1b3f1..99cd4cc 100644
--- a/src/command_apply_changes.cpp
+++ b/src/command_apply_changes.cpp
@@ -34,12 +34,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
bool CommandApplyChanges::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
cmdline.add_options()
- ("input-format,F", po::value<std::string>(), "Format of input file")
("simplify,s", "Simplify change")
("remove-deleted,r", "Remove deleted objects from output")
;
add_common_options(cmdline);
+ add_single_input_options(cmdline);
add_output_options(cmdline);
po::options_description hidden("Hidden options");
diff --git a/src/command_cat.cpp b/src/command_cat.cpp
index 72e3c14..b4fe8a6 100644
--- a/src/command_cat.cpp
+++ b/src/command_cat.cpp
@@ -33,11 +33,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
bool CommandCat::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
cmdline.add_options()
- ("input-format,F", po::value<std::string>(), "Format of input files")
("object-type,t", po::value<std::vector<std::string>>(), "Read only objects of given type (node, way, relation, changeset)")
;
add_common_options(cmdline);
+ add_multiple_inputs_options(cmdline);
add_output_options(cmdline);
po::options_description hidden("Hidden options");
diff --git a/src/command_check_refs.cpp b/src/command_check_refs.cpp
index c17adce..d11cb59 100644
--- a/src/command_check_refs.cpp
+++ b/src/command_check_refs.cpp
@@ -38,11 +38,11 @@ bool CommandCheckRefs::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
cmdline.add_options()
("show-ids,i", "Show IDs of missing objects")
- ("input-format,F", po::value<std::string>(), "Format of input files")
("check-relations,r", "Also check relations")
;
add_common_options(cmdline);
+ add_single_input_options(cmdline);
po::options_description hidden("Hidden options");
hidden.add_options()
@@ -60,6 +60,7 @@ bool CommandCheckRefs::setup(const std::vector<std::string>& arguments) {
po::notify(vm);
setup_common(vm);
+ setup_input_file(vm);
if (vm.count("show-ids")) {
m_show_ids = true;
@@ -77,8 +78,6 @@ bool CommandCheckRefs::setup(const std::vector<std::string>& arguments) {
m_vout << " show ids: " << (m_show_ids ? "yes\n" : "no\n");
m_vout << " check relations: " << (m_check_relations ? "yes\n" : "no\n");
- setup_input_file(vm);
-
return true;
}
diff --git a/src/command_fileinfo.cpp b/src/command_fileinfo.cpp
index 8897791..1754ce2 100644
--- a/src/command_fileinfo.cpp
+++ b/src/command_fileinfo.cpp
@@ -486,10 +486,11 @@ bool CommandFileinfo::setup(const std::vector<std::string>& arguments) {
("extended,e", "Extended output")
("get,g", po::value<std::string>(), "Get value")
("show-variables,G", "Show variables for --get option")
- ("input-format,F", po::value<std::string>(), "Format of input file")
("json,j", "JSON output")
;
+ add_single_input_options(cmdline);
+
po::options_description hidden("Hidden options");
hidden.add_options()
("input-filename", po::value<std::string>(), "Input file")
@@ -505,6 +506,8 @@ bool CommandFileinfo::setup(const std::vector<std::string>& arguments) {
po::store(po::command_line_parser(arguments).options(desc).positional(positional).run(), vm);
po::notify(vm);
+ setup_input_file(vm);
+
if (vm.count("extended")) {
m_extended = true;
}
@@ -561,8 +564,6 @@ bool CommandFileinfo::setup(const std::vector<std::string>& arguments) {
throw argument_error("You can not use --get/-g and --json/-j together.");
}
- setup_input_file(vm);
-
return true;
}
diff --git a/src/command_getid.cpp b/src/command_getid.cpp
index 5dbd4fc..859ce0b 100644
--- a/src/command_getid.cpp
+++ b/src/command_getid.cpp
@@ -46,11 +46,9 @@ void CommandGetId::sort_unique(osmium::item_type type) {
bool CommandGetId::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
- cmdline.add_options()
- ("input-format,F", po::value<std::string>(), "Format of input file")
- ;
add_common_options(cmdline);
+ add_single_input_options(cmdline);
add_output_options(cmdline);
po::options_description hidden("Hidden options");
diff --git a/src/command_merge_changes.cpp b/src/command_merge_changes.cpp
index 15de8ae..9f80320 100644
--- a/src/command_merge_changes.cpp
+++ b/src/command_merge_changes.cpp
@@ -35,11 +35,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
bool CommandMergeChanges::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
cmdline.add_options()
- ("input-format,F", po::value<std::string>(), "Format of input files")
("simplify,s", "Simplify change")
;
add_common_options(cmdline);
+ add_multiple_inputs_options(cmdline);
add_output_options(cmdline);
po::options_description hidden("Hidden options");
diff --git a/src/command_renumber.cpp b/src/command_renumber.cpp
index d36ed37..30d478c 100644
--- a/src/command_renumber.cpp
+++ b/src/command_renumber.cpp
@@ -43,11 +43,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
bool CommandRenumber::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
cmdline.add_options()
- ("input-format,F", po::value<std::string>(), "Format of input files")
("index-directory,i", po::value<std::string>(), "Index directory")
;
add_common_options(cmdline);
+ add_single_input_options(cmdline);
add_output_options(cmdline);
po::options_description hidden("Hidden options");
diff --git a/src/command_time_filter.cpp b/src/command_time_filter.cpp
index 2cf53ba..13ec393 100644
--- a/src/command_time_filter.cpp
+++ b/src/command_time_filter.cpp
@@ -32,11 +32,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
bool CommandTimeFilter::setup(const std::vector<std::string>& arguments) {
po::options_description cmdline("Allowed options");
- cmdline.add_options()
- ("input-format,F", po::value<std::string>(), "Format of input file")
- ;
add_common_options(cmdline);
+ add_single_input_options(cmdline);
add_output_options(cmdline);
po::options_description hidden("Hidden options");
diff --git a/src/osmc.hpp b/src/osmc.hpp
index f2b627f..55ea8cf 100644
--- a/src/osmc.hpp
+++ b/src/osmc.hpp
@@ -127,6 +127,12 @@ public:
m_input_file = osmium::io::File(m_input_filename, m_input_format);
}
+ void add_single_input_options(po::options_description& options) {
+ options.add_options()
+ ("input-format,F", po::value<std::string>(), "Format of input file")
+ ;
+ }
+
}; // class with_single_osm_input
class with_multiple_osm_inputs {
@@ -168,6 +174,12 @@ public:
}
}
+ void add_multiple_inputs_options(po::options_description& options) {
+ options.add_options()
+ ("input-format,F", po::value<std::string>(), "Format of input files")
+ ;
+ }
+
}; // class with_multiple_osm_inputs
class with_osm_output {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osmium-tool.git
More information about the Pkg-grass-devel
mailing list