[osmium-tool] 40/44: Refactoring: Put display of arguments (verbose mode) into extra 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 8988b30aa62b9d0223c49e88bbe80527d079f32b
Author: Jochen Topf <jochen at topf.org>
Date: Fri Jul 3 15:41:53 2015 +0200
Refactoring: Put display of arguments (verbose mode) into extra function.
---
src/command_apply_changes.cpp | 6 ++++--
src/command_apply_changes.hpp | 2 ++
src/command_cat.cpp | 6 ++++--
src/command_cat.hpp | 2 ++
src/command_check_refs.cpp | 7 ++++---
src/command_check_refs.hpp | 2 ++
src/command_fileinfo.cpp | 9 +++++++++
src/command_fileinfo.hpp | 2 ++
src/command_getid.cpp | 6 ++++--
src/command_getid.hpp | 2 ++
src/command_merge_changes.cpp | 6 ++++--
src/command_merge_changes.hpp | 2 ++
src/command_renumber.cpp | 6 ++++--
src/command_renumber.hpp | 2 ++
src/command_time_filter.cpp | 6 ++++--
src/command_time_filter.hpp | 2 ++
src/main.cpp | 1 +
src/osmc.hpp | 11 +++++++++++
18 files changed, 65 insertions(+), 15 deletions(-)
diff --git a/src/command_apply_changes.cpp b/src/command_apply_changes.cpp
index 99cd4cc..4cc3a3d 100644
--- a/src/command_apply_changes.cpp
+++ b/src/command_apply_changes.cpp
@@ -75,6 +75,10 @@ bool CommandApplyChanges::setup(const std::vector<std::string>& arguments) {
m_remove_deleted = true;
}
+ return true;
+}
+
+void CommandApplyChanges::show_arguments() {
m_vout << "Started osmium apply-changes\n";
m_vout << "Command line options and default settings:\n";
@@ -87,8 +91,6 @@ bool CommandApplyChanges::setup(const std::vector<std::string>& arguments) {
m_vout << " output filename: " << m_output_filename << "\n";
m_vout << " input format: " << m_input_format << "\n";
m_vout << " output format: " << m_output_format << "\n";
-
- return true;
}
/**
diff --git a/src/command_apply_changes.hpp b/src/command_apply_changes.hpp
index 1db7eae..6a9161e 100644
--- a/src/command_apply_changes.hpp
+++ b/src/command_apply_changes.hpp
@@ -41,6 +41,8 @@ public:
bool setup(const std::vector<std::string>& arguments) override final;
+ void show_arguments() override final;
+
bool run() override final;
}; // class CommandApplyChanges
diff --git a/src/command_cat.cpp b/src/command_cat.cpp
index b4fe8a6..336f336 100644
--- a/src/command_cat.cpp
+++ b/src/command_cat.cpp
@@ -76,6 +76,10 @@ bool CommandCat::setup(const std::vector<std::string>& arguments) {
}
}
+ return true;
+}
+
+void CommandCat::show_arguments() {
m_vout << "Started osmium cat\n";
m_vout << "Command line options and default settings:\n";
@@ -105,8 +109,6 @@ bool CommandCat::setup(const std::vector<std::string>& arguments) {
m_vout << " changeset";
}
m_vout << "\n";
-
- return true;
}
bool CommandCat::run() {
diff --git a/src/command_cat.hpp b/src/command_cat.hpp
index 252256c..8607053 100644
--- a/src/command_cat.hpp
+++ b/src/command_cat.hpp
@@ -40,6 +40,8 @@ public:
bool setup(const std::vector<std::string>& arguments) override final;
+ void show_arguments() override final;
+
bool run() override final;
}; // class CommandCat
diff --git a/src/command_check_refs.cpp b/src/command_check_refs.cpp
index d11cb59..a610bbc 100644
--- a/src/command_check_refs.cpp
+++ b/src/command_check_refs.cpp
@@ -70,6 +70,10 @@ bool CommandCheckRefs::setup(const std::vector<std::string>& arguments) {
m_check_relations = true;
}
+ return true;
+}
+
+void CommandCheckRefs::show_arguments() {
m_vout << "Started osmium check-refs\n";
m_vout << "Command line options and default settings:\n";
@@ -77,11 +81,8 @@ bool CommandCheckRefs::setup(const std::vector<std::string>& arguments) {
m_vout << " input format: " << m_input_format << "\n";
m_vout << " show ids: " << (m_show_ids ? "yes\n" : "no\n");
m_vout << " check relations: " << (m_check_relations ? "yes\n" : "no\n");
-
- return true;
}
-
class RefCheckHandler : public osmium::handler::Handler {
osmium::index::BoolVector<osmium::unsigned_object_id_type> m_nodes;
diff --git a/src/command_check_refs.hpp b/src/command_check_refs.hpp
index d8bfbea..a115af8 100644
--- a/src/command_check_refs.hpp
+++ b/src/command_check_refs.hpp
@@ -38,6 +38,8 @@ public:
bool setup(const std::vector<std::string>& arguments) override final;
+ void show_arguments() override final;
+
bool run() override final;
}; // class CommandCheckRefs
diff --git a/src/command_fileinfo.cpp b/src/command_fileinfo.cpp
index 1754ce2..9597232 100644
--- a/src/command_fileinfo.cpp
+++ b/src/command_fileinfo.cpp
@@ -567,6 +567,15 @@ bool CommandFileinfo::setup(const std::vector<std::string>& arguments) {
return true;
}
+void CommandFileinfo::show_arguments() {
+ m_vout << "Started osmium fileinfo\n";
+
+ m_vout << "Command line options and default settings:\n";
+ m_vout << " input filename: " << m_input_filename << "\n";
+ m_vout << " input format: " << m_input_format << "\n";
+ m_vout << " extended output: " << (m_extended ? "yes\n" : "no\n");
+}
+
bool CommandFileinfo::run() {
std::unique_ptr<Output> output;
if (m_json_output) {
diff --git a/src/command_fileinfo.hpp b/src/command_fileinfo.hpp
index 497954f..8b23e5c 100644
--- a/src/command_fileinfo.hpp
+++ b/src/command_fileinfo.hpp
@@ -41,6 +41,8 @@ public:
bool setup(const std::vector<std::string>& arguments) override final;
+ void show_arguments() override final;
+
bool run() override final;
}; // class CommandFileinfo
diff --git a/src/command_getid.cpp b/src/command_getid.cpp
index 859ce0b..323427b 100644
--- a/src/command_getid.cpp
+++ b/src/command_getid.cpp
@@ -93,6 +93,10 @@ bool CommandGetId::setup(const std::vector<std::string>& arguments) {
throw argument_error("Need at least one id to look for...");
}
+ return true;
+}
+
+void CommandGetId::show_arguments() {
m_vout << "Started osmium apply-changes\n";
m_vout << "Command line options and default settings:\n";
@@ -117,8 +121,6 @@ bool CommandGetId::setup(const std::vector<std::string>& arguments) {
m_vout << " " << id;
}
m_vout << "\n";
-
- return true;
}
bool CommandGetId::run() {
diff --git a/src/command_getid.hpp b/src/command_getid.hpp
index 7a6a309..454c880 100644
--- a/src/command_getid.hpp
+++ b/src/command_getid.hpp
@@ -45,6 +45,8 @@ public:
bool setup(const std::vector<std::string>& arguments) override final;
+ void show_arguments() override final;
+
bool run() override final;
}; // class CommandGetId
diff --git a/src/command_merge_changes.cpp b/src/command_merge_changes.cpp
index 9f80320..b49e668 100644
--- a/src/command_merge_changes.cpp
+++ b/src/command_merge_changes.cpp
@@ -65,6 +65,10 @@ bool CommandMergeChanges::setup(const std::vector<std::string>& arguments) {
m_simplify_change = true;
}
+ return true;
+}
+
+void CommandMergeChanges::show_arguments() {
m_vout << "Started osmium merge-changes\n";
m_vout << "Command line options and default settings:\n";
@@ -76,8 +80,6 @@ bool CommandMergeChanges::setup(const std::vector<std::string>& arguments) {
m_vout << " output filename: " << m_output_filename << "\n";
m_vout << " input format: " << m_input_format << "\n";
m_vout << " output format: " << m_output_format << "\n";
-
- return true;
}
bool CommandMergeChanges::run() {
diff --git a/src/command_merge_changes.hpp b/src/command_merge_changes.hpp
index 42c2312..3813411 100644
--- a/src/command_merge_changes.hpp
+++ b/src/command_merge_changes.hpp
@@ -38,6 +38,8 @@ public:
bool setup(const std::vector<std::string>& arguments) override final;
+ void show_arguments() override final;
+
bool run() override final;
}; // class CommandMergeChanges
diff --git a/src/command_renumber.cpp b/src/command_renumber.cpp
index 30d478c..07aba8d 100644
--- a/src/command_renumber.cpp
+++ b/src/command_renumber.cpp
@@ -73,6 +73,10 @@ bool CommandRenumber::setup(const std::vector<std::string>& arguments) {
m_index_directory = vm["index-directory"].as<std::string>();
}
+ return true;
+}
+
+void CommandRenumber::show_arguments() {
m_vout << "Started osmium renumber\n";
m_vout << "Command line options and default settings:\n";
@@ -86,8 +90,6 @@ bool CommandRenumber::setup(const std::vector<std::string>& arguments) {
m_vout << " " << h << "\n";
}
m_vout << " index directory: " << m_index_directory << "\n";
-
- return true;
}
osmium::object_id_type CommandRenumber::lookup(osmium::item_type type, osmium::object_id_type id) {
diff --git a/src/command_renumber.hpp b/src/command_renumber.hpp
index d7f0483..c92d80a 100644
--- a/src/command_renumber.hpp
+++ b/src/command_renumber.hpp
@@ -48,6 +48,8 @@ public:
bool setup(const std::vector<std::string>& arguments) override final;
+ void show_arguments() override final;
+
osmium::object_id_type lookup(osmium::item_type type, osmium::object_id_type id);
void renumber(osmium::memory::Buffer& buffer);
diff --git a/src/command_time_filter.cpp b/src/command_time_filter.cpp
index 13ec393..deb2c3d 100644
--- a/src/command_time_filter.cpp
+++ b/src/command_time_filter.cpp
@@ -87,10 +87,12 @@ bool CommandTimeFilter::setup(const std::vector<std::string>& arguments) {
}
}
+ return true;
+}
+
+void CommandTimeFilter::show_arguments() {
m_vout << "Started osmium time-filter\n";
m_vout << "Filtering from time " << m_from.to_iso() << " to " << m_to.to_iso() << "\n";
-
- return true;
}
bool CommandTimeFilter::run() {
diff --git a/src/command_time_filter.hpp b/src/command_time_filter.hpp
index 1ec4382..a49e3b7 100644
--- a/src/command_time_filter.hpp
+++ b/src/command_time_filter.hpp
@@ -41,6 +41,8 @@ public:
bool setup(const std::vector<std::string>& arguments) override final;
+ void show_arguments() override final;
+
bool run() override final;
}; // class CommandTimeFilter
diff --git a/src/main.cpp b/src/main.cpp
index a39295a..47d9b2f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -104,6 +104,7 @@ int main(int argc, char *argv[]) {
return return_code::fatal;
}
+ cmd->print_arguments();
bool result = cmd->run();
google::protobuf::ShutdownProtobufLibrary();
diff --git a/src/osmc.hpp b/src/osmc.hpp
index 55ea8cf..33636d2 100644
--- a/src/osmc.hpp
+++ b/src/osmc.hpp
@@ -82,6 +82,11 @@ public:
return true;
}
+ // Show command line arguments. This is only called when the
+ // verbose option is true;
+ virtual void show_arguments() {
+ }
+
// Run the actual command.
// It returns true if everything ran successfully.
// It returns false if there was an error.
@@ -99,6 +104,12 @@ public:
}
}
+ void print_arguments() {
+ if (m_vout.verbose()) {
+ show_arguments();
+ }
+ }
+
}; // class Command
class with_single_osm_input {
--
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