Skip to content

Commit

Permalink
Use clara.hpp for command line parsing instead of getopt.
Browse files Browse the repository at this point in the history
This also works on Windows. Clara is from
https://github.com/catchorg/Clara .

Fixes #20.
  • Loading branch information
joto committed Feb 21, 2018
1 parent 533b811 commit 70fc232
Show file tree
Hide file tree
Showing 5 changed files with 1,385 additions and 141 deletions.
28 changes: 28 additions & 0 deletions EXTERNAL_LICENSES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

==== clara.hpp

Copyright 2017 Two Blue Cubes Ltd. All rights reserved.

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
96 changes: 47 additions & 49 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,71 +16,69 @@ add_executable(vtzero-stats vtzero-stats.cpp utils.cpp)

add_executable(vtzero-streets vtzero-streets.cpp utils.cpp)

# disable building of examples that need getopt lib on MSVC
if(NOT MSVC)
add_executable(vtzero-filter vtzero-filter.cpp utils.cpp)
#-------------------------------------------------------------

add_test(NAME vtzero-filter-empty
COMMAND vtzero-filter)
set_tests_properties(vtzero-filter-empty PROPERTIES
PASS_REGULAR_EXPRESSION "^Usage: ")
add_executable(vtzero-filter vtzero-filter.cpp utils.cpp)

add_test(NAME vtzero-filter-help
COMMAND vtzero-filter -h)
set_tests_properties(vtzero-filter-help PROPERTIES
PASS_REGULAR_EXPRESSION "^vtzero-filter ")
add_test(NAME vtzero-filter-empty
COMMAND vtzero-filter)
set_tests_properties(vtzero-filter-empty PROPERTIES
PASS_REGULAR_EXPRESSION "^Error in command line: Missing file name of vector tile to read")

add_test(NAME vtzero-filter-layer
COMMAND vtzero-filter -o ${CMAKE_CURRENT_BINARY_DIR}/bridges.mvt ${TEST_FILE} bridge)
add_test(NAME vtzero-filter-help
COMMAND vtzero-filter -h)
set_tests_properties(vtzero-filter-help PROPERTIES
PASS_REGULAR_EXPRESSION "^usage:\n vtzero-filter ")

add_test(NAME vtzero-filter-feature
COMMAND vtzero-filter -o ${CMAKE_CURRENT_BINARY_DIR}/bridges.mvt ${TEST_FILE} waterway_label 221925711)
add_test(NAME vtzero-filter-layer
COMMAND vtzero-filter -o ${CMAKE_CURRENT_BINARY_DIR}/bridges.mvt ${TEST_FILE} bridge)

add_test(NAME vtzero-filter-invalid-id
COMMAND vtzero-filter -o ${CMAKE_CURRENT_BINARY_DIR}/bridges.mvt ${TEST_FILE} waterway_label abc)
set_tests_properties(vtzero-filter-invalid-id PROPERTIES
WILL_FAIL true)
add_test(NAME vtzero-filter-feature
COMMAND vtzero-filter -o ${CMAKE_CURRENT_BINARY_DIR}/bridges.mvt ${TEST_FILE} waterway_label 221925711)

#-------------------------------------------------------------
add_test(NAME vtzero-filter-invalid-id
COMMAND vtzero-filter -o ${CMAKE_CURRENT_BINARY_DIR}/bridges.mvt ${TEST_FILE} waterway_label abc)
set_tests_properties(vtzero-filter-invalid-id PROPERTIES
WILL_FAIL true)

add_executable(vtzero-show vtzero-show.cpp utils.cpp)
#-------------------------------------------------------------

add_test(NAME vtzero-show-empty
COMMAND vtzero-show)
set_tests_properties(vtzero-show-empty PROPERTIES
PASS_REGULAR_EXPRESSION "^Usage: ")
add_executable(vtzero-show vtzero-show.cpp utils.cpp)

add_test(NAME vtzero-show-help
COMMAND vtzero-show -h)
set_tests_properties(vtzero-show-help PROPERTIES
PASS_REGULAR_EXPRESSION "^vtzero-show ")
add_test(NAME vtzero-show-empty
COMMAND vtzero-show)
set_tests_properties(vtzero-show-empty PROPERTIES
PASS_REGULAR_EXPRESSION "^Error in command line: Missing file name of vector tile to read")

add_test(NAME vtzero-show-layers
COMMAND vtzero-show -l ${TEST_FILE})
set_tests_properties(vtzero-show-layers PROPERTIES
PASS_REGULAR_EXPRESSION "^landuse 78\nwaterway 327\n.*\nwaterway_label 4\n$")
add_test(NAME vtzero-show-help
COMMAND vtzero-show -h)
set_tests_properties(vtzero-show-help PROPERTIES
PASS_REGULAR_EXPRESSION "^usage:\n vtzero-show ")

add_test(NAME vtzero-show-layer-num
COMMAND vtzero-show ${TEST_FILE} 2)
set_tests_properties(vtzero-show-layer-num PROPERTIES
PASS_REGULAR_EXPRESSION "layer: [0-9]+\n name: water\n")
add_test(NAME vtzero-show-layers
COMMAND vtzero-show -l ${TEST_FILE})
set_tests_properties(vtzero-show-layers PROPERTIES
PASS_REGULAR_EXPRESSION "^landuse 78\nwaterway 327\n.*\nwaterway_label 4\n$")

add_test(NAME vtzero-show-layer-name
COMMAND vtzero-show ${CMAKE_SOURCE_DIR}/test/data/mapbox-streets-v6-14-8714-8017.mvt water)
set_tests_properties(vtzero-show-layer-name PROPERTIES
PASS_REGULAR_EXPRESSION "layer: [0-9]+\n name: water\n")
add_test(NAME vtzero-show-layer-num
COMMAND vtzero-show ${TEST_FILE} 2)
set_tests_properties(vtzero-show-layer-num PROPERTIES
PASS_REGULAR_EXPRESSION "layer: [0-9]+\n name: water\n")

#-------------------------------------------------------------
add_test(NAME vtzero-show-layer-name
COMMAND vtzero-show ${CMAKE_SOURCE_DIR}/test/data/mapbox-streets-v6-14-8714-8017.mvt water)
set_tests_properties(vtzero-show-layer-name PROPERTIES
PASS_REGULAR_EXPRESSION "layer: [0-9]+\n name: water\n")

file(GLOB ext_tests RELATIVE ${CMAKE_SOURCE_DIR}/test/data/ ${CMAKE_SOURCE_DIR}/test/data/ext*)
#-------------------------------------------------------------

foreach(_test IN LISTS ext_tests)
message(STATUS "Adding ext test: ${_test}")
add_test(NAME ext-tests-${_test}
COMMAND vtzero-show ${CMAKE_SOURCE_DIR}/test/data/${_test})
endforeach()
file(GLOB ext_tests RELATIVE ${CMAKE_SOURCE_DIR}/test/data/ ${CMAKE_SOURCE_DIR}/test/data/ext*)

endif()
foreach(_test IN LISTS ext_tests)
message(STATUS "Adding ext test: ${_test}")
add_test(NAME ext-tests-${_test}
COMMAND vtzero-show ${CMAKE_SOURCE_DIR}/test/data/${_test})
endforeach()


#-----------------------------------------------------------------------------
Loading

0 comments on commit 70fc232

Please sign in to comment.