Skip to content

Commit 619ff61

Browse files
Update README.md
1 parent 4855a4a commit 619ff61

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Have you ever built a simple ```C++``` CLI program and end up needing to write d
1414
> This library automatically fetches the ![CppSafeIO library](https://github.com/DanielRamirez404/CppSafeIO), since it's required to work. Thus, you don't have to directly include it.
1515
1616
> [!TIP]
17-
> The simplest way to implement this library in your projects would be by fetching the library as a subdirectory of a given project's ```CMake``` script, and ultimately, make use of ```include_directory()``` to execute this directory's ```CMakeLists.txt```, which makes it possible to use ```target_link_libraries()``` with your executable and the ```CPP_SAFE_IO``` variable, as follows:
17+
> The simplest way to implement this library in your projects would be by fetching the library as a subdirectory of a given project's ```CMake``` script, and ultimately, make use of ```include_directory()``` to execute this directory's ```CMakeLists.txt```, which makes it possible to use ```target_link_libraries()``` with your executable and the ```CPP_MENU``` variable, as follows:
1818
1919
Your project's directory structure:
2020
```
@@ -34,9 +34,6 @@ target_link_libraries(YourExecutable ${CPP_MENU})
3434
...
3535
```
3636

37-
> [!NOTE]
38-
> This approach is used by this project's ```tests``` directory.
39-
4037
Nonetheless, I highly recommend making use of a second, cleaner approach where you don't have to directly include the library as one of your project's subdirectories:
4138

4239
> [!IMPORTANT]
@@ -52,8 +49,8 @@ include(FetchContent)
5249
5350
FetchContent_Declare( cppmenu
5451
GIT_REPOSITORY https://github.com/DanielRamirez404/CppMenu.git
55-
GIT_TAG v1.0.0
56-
GIT_SHALLOW TRUE
52+
GIT_TAG v2.0.0
53+
GIT_SHALLOW TRUE
5754
)
5855
5956
FetchContent_MakeAvailable(cppmenu)
@@ -66,6 +63,12 @@ target_link_libraries(YourExecutable ${CPP_MENU})
6663
> [!NOTE]
6764
> You can optionally change the value of the ```CPP_MENU``` variable before the ```FetchContent_MakeAvailable()``` call, if you wish so, since it won't be overwritten and it'll show up when building the project.
6865
66+
> [!IMPORTANT]
67+
> If you want to use ```Windows```'s ```conio.h``` header file's functions in this library, you should set the ```INCLUDE_CONIO_FOR_IO``` option to ```ON```, since it's automatically off. You can try something like this on your project's main ```CMakeLists.txt```:
68+
>```
69+
> option(INCLUDE_CONIO_FOR_IO "Flag for including the conio.h header file" ON)
70+
> ```
71+
6972
## How to use
7073
7174
You only need to include the ```cppmenu.h``` header file. Henceforth, all of the library's functions and classes will be available inside of the ```CppMenu``` namespace, similarly to the ```std``` namespace of the ```C++ Standard Library```. To use a menu, you just initialize a ```Cpp::Menu::CommonMenu``` or ```Cpp::Menu::DisplayOnceMenu``` object and use the ```run()``` method. Here's a simple example showcasing a program that uses a ```Cpp::Menu::CommonMenu``` object:
@@ -157,7 +160,17 @@ Both menu classes have a public ```run()``` method which you can use to call you
157160
> [!NOTE]
158161
> If any of your functions throws an exception, it'll be safely caught, logged into the console and then the program's execution will be resumed. You can check this out in the ```tests``` subdirectory.
159162
160-
## Testing
163+
## Building & Testing
164+
165+
You can also just build and test the library independently from your projects, here's an example using ```bash``` in the library's directory:
166+
167+
```
168+
cmake -B build -DCMAKE_BUILD_TYPE=Release -S . && cmake --build build --config Release && cd build && ctest -V && cd ..
169+
```
170+
171+
As you can see, ```CMake``` is used to build the project and ```CTest``` to run the automated tests (the ```CppMenu-AutomatedTests``` and ```CppSafeIO-AutomatedTests``` executables)!
161172
162173
> [!TIP]
163-
> You can test this library's functions in the ```tests``` subdirectory.
174+
> If you wish to test out this library's functions, you can run the ```CppMenu-Tests``` executable (same goes for the ```CppSafeIO``` library). If it doesn't throw any exceptions or show any anomalies while getting input or cleaning output, then it should be working properly.
175+
176+
*Both of this library's tests' source code are available on the ```tests``` directory.*

0 commit comments

Comments
 (0)