Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
All changes to the repository will be reported here

## [0.2.1]
### Updated
- README file with optarg struct usage

## [0.2.0]
### Changed
- Debug build type in CI
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Author Marco M. Mosca, email: marcomichele.mosca@gmail.com
]]

cmake_minimum_required(VERSION 3.5.0)
project(cmd-api VERSION 0.2.0 LANGUAGES C)
project(cmd-api VERSION 0.2.1 LANGUAGES C)

include(CTest)

Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,22 @@ install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib)
```
#include "cmd-api.h"
int main(int argc, char* argv[]) {
char* w;
while ((w = getoptW(argc, argv, "o:|opt1:|opt2:|")) != NULL)
optarg_t* optarg;
while ((optarg = getoptW(argc, argv, "o:|opt1:|opt2:|")) != NULL)
{
if (strcmp(w, "o") == 0) {
/*use optargW that has the argument of o*/
if (strcmp(optarg->opt, "o") == 0) {
/*use optarg->arg that has the argument of o*/
continue;
}
if (strcmp(w, "opt1") == 0) {
/*use optargW that has the argument of opt1*/
if (strcmp(optarg->opt, "opt1") == 0) {
/*use optarg->arg that has the argument of opt1*/
continue;
}
if (strcmp(w, "opt2") == 0) {
/*use optargW that has the argument of opt2*/
if (strcmp(optarg->opt, "opt2") == 0) {
/*use optarg->arg that has the argument of opt2*/
continue;
}
free(optarg);
}
...
}
Expand Down