File tree Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 4747 - name : Check coverage
48484949 with :
50- excludes : build/*
50+ excludes : |
51+ build/*
52+ src/main.cpp
5153 fail-under-line : 80
Original file line number Diff line number Diff line change @@ -7,13 +7,19 @@ file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.38.7/C
77include (${CMAKE_BINARY_DIR} /_deps/CPM.cmake)
88cpmusepackagelock(package-lock)
99
10+ cpmgetpackage(argparse)
1011cpmgetpackage(CheckWarning.cmake)
1112
1213add_library (my_fibonacci src/sequence.cpp)
1314target_include_directories (my_fibonacci PUBLIC include )
1415set_property (TARGET my_fibonacci PROPERTY CXX_STANDARD 11)
1516target_check_warning(my_fibonacci)
1617
18+ add_executable (my_fibonacci_main src/main.cpp)
19+ target_link_libraries (my_fibonacci_main PUBLIC argparse my_fibonacci)
20+ set_property (TARGET my_fibonacci_main PROPERTY CXX_STANDARD 11)
21+ target_check_warning(my_fibonacci_main)
22+
1723if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR )
1824 cpmgetpackage(Format.cmake)
1925
Original file line number Diff line number Diff line change 11# CPM Package Lock
22# This file should be committed to version control
33
4+ # argparse
5+ CPMDeclarePackage(argparse
6+ VERSION 3.0
7+ GITHUB_REPOSITORY p-ranav/argparse
8+ SYSTEM YES
9+ EXCLUDE_FROM_ALL YES
10+ )
411# CheckWarning.cmake
512CPMDeclarePackage(CheckWarning.cmake
613 VERSION 1.0.0
Original file line number Diff line number Diff line change 1+ #include < argparse/argparse.hpp>
2+ #include < cstdlib>
3+ #include < iostream>
4+ #include < my_fibonacci/sequence.hpp>
5+
6+ int main (int argc, char ** argv) {
7+ argparse::ArgumentParser program (" my_fibonacci_main" );
8+ program.add_description (
9+ " Generate a Fibonacci sequence up to the given number of terms." );
10+ program.add_argument (" n" ).help (" The number of terms" ).scan <' i' , int >();
11+
12+ try {
13+ program.parse_args (argc, argv);
14+ } catch (const std::exception& err) {
15+ std::cerr << err.what () << std::endl;
16+ std::cerr << program;
17+ return 1 ;
18+ }
19+
20+ const auto n = program.get <int >(" n" );
21+ const auto sequence = my_fibonacci::fibonacci_sequence (n);
22+ for (auto val : sequence) {
23+ std::cout << val << " " ;
24+ }
25+ std::cout << std::endl;
26+
27+ return 0 ;
28+ }
You can’t perform that action at this time.
0 commit comments