You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-8Lines changed: 21 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ Have you ever built a simple ```C++``` CLI program and end up needing to write d
14
14
> This library automatically fetches the , since it's required to work. Thus, you don't have to directly include it.
15
15
16
16
> [!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:
> This approach is used by this project's ```tests``` directory.
39
-
40
37
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:
> 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.
68
65
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
+
69
72
## How to use
70
73
71
74
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
157
160
> [!NOTE]
158
161
> 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.
159
162
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:
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)!
161
172
162
173
> [!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