Skip to content
Snippets Groups Projects
Commit 15ee6264 authored by webmanue's avatar webmanue
Browse files

add a cmdline example

parent 162d3ccc
No related branches found
No related tags found
No related merge requests found
......@@ -16,4 +16,5 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
add_subdirectory(src)
add_subdirectory(examples)
add_subdirectory(test)
# © 2020 ETH Zurich, Mechanics and Materials Lab
# © 2020 California Institute of Technology
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
add_executable(${PROJECT_NAME}-CmdLineExample
./Example.cc
)
target_link_libraries(${PROJECT_NAME}-CmdLineExample
PRIVATE ${PROJECT_NAME}::cmdline
)
// © 2020 ETH Zurich, Mechanics and Materials Lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <ae108/cmdline/CommandLineOptionParser.h>
#include <iostream>
int main(const int argc, const char *const *const argv) {
namespace cmdline = ae108::cmdline;
auto enable_greeting = bool{false};
cmdline::CommandLineOptionParser(std::cerr)
.withOption("enable_greeting,g", "Print a greeting.", &enable_greeting)
.parse(argc, argv);
if (enable_greeting) {
std::cout << "Hello world!" << std::endl;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment