@@ -76,17 +76,21 @@ bool CommandSort::setup(const std::vector<std::string>& arguments) {
76
76
setup_input_files (vm);
77
77
setup_output_file (vm);
78
78
79
- if (vm.count (" input-filenames" )) {
80
- m_filenames = vm[" input-filenames" ].as <std::vector<std::string>>();
81
- }
82
-
83
79
if (vm.count (" strategy" )) {
84
80
m_strategy = vm[" strategy" ].as <std::string>();
85
81
if (m_strategy != " simple" && m_strategy != " multipass" ) {
86
82
throw argument_error{" Unknown strategy: " + m_strategy};
87
83
}
88
84
}
89
85
86
+ if (m_strategy == " multipass" ) {
87
+ if (std::any_of (m_input_filenames.cbegin (), m_input_filenames.cend (), [&](const std::string& name) {
88
+ return name == " -" ;
89
+ })) {
90
+ throw argument_error{" Can not read from STDIN when using multipass strategy" };
91
+ }
92
+ }
93
+
90
94
return true ;
91
95
}
92
96
@@ -110,8 +114,8 @@ bool CommandSort::run_single_pass() {
110
114
111
115
m_vout << " Reading contents of input files...\n " ;
112
116
osmium::ProgressBar progress_bar{file_size_sum (m_input_files), display_progress ()};
113
- for (const std::string& file_name : m_filenames ) {
114
- osmium::io::Reader reader{file_name , osmium::osm_entity_bits::object};
117
+ for (const auto & file : m_input_files ) {
118
+ osmium::io::Reader reader{file , osmium::osm_entity_bits::object};
115
119
const osmium::io::Header header{reader.header ()};
116
120
bounding_box.extend (header.joined_boxes ());
117
121
while (osmium::memory::Buffer buffer = reader.read ()) {
@@ -167,8 +171,8 @@ bool CommandSort::run_multi_pass() {
167
171
osmium::Box bounding_box;
168
172
169
173
m_vout << " Reading input file headers...\n " ;
170
- for (const std::string& file_name : m_filenames ) {
171
- osmium::io::Reader reader{file_name , osmium::osm_entity_bits::nothing};
174
+ for (const auto & file : m_input_files ) {
175
+ osmium::io::Reader reader{file , osmium::osm_entity_bits::nothing};
172
176
const osmium::io::Header header{reader.header ()};
173
177
bounding_box.extend (header.joined_boxes ());
174
178
reader.close ();
@@ -196,8 +200,8 @@ bool CommandSort::run_multi_pass() {
196
200
197
201
m_vout << " Pass " << pass++ << " ...\n " ;
198
202
m_vout << " Reading contents of input files...\n " ;
199
- for (const std::string& file_name : m_filenames ) {
200
- osmium::io::Reader reader{file_name , entity};
203
+ for (const auto & file : m_input_files ) {
204
+ osmium::io::Reader reader{file , entity};
201
205
const osmium::io::Header read_header{reader.header ()};
202
206
bounding_box.extend (read_header.joined_boxes ());
203
207
while (osmium::memory::Buffer buffer = reader.read ()) {
0 commit comments