Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A C argument parser for basic usages

License

Nickys0/Anter.h

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anter.h

A simple only header library for parsing command line arguments

EXAMPLE

#define ANTER_IMPLEMENTATION
#include "Anter.h"

int main(int argc, char** argv) {
    bool flag = false;
    ant_init(argc, argv); /* for internally setting argc, argv */

    /* The last argument is not implemented yet so you can just put NULL in here */
    ant_flag_bool(&flag, "--bool", "-b", NULL); 

    /* ant_strerror returns a simple error msg, it uses an 
        internal buffer so no malloc required */
    if(ant_parse() != ANTERR_NONE)
        fprintf(stderr, "error: %s", ant_strerror());

    ...
    ant_clean( ); // Deallocates and setting the internal state to an invalid one
    return 0;
}

Testing

For testing the library we use the nob.h library. Here is how to test:

gcc -o nob nob.c

and then you can just run it to test all the files:

./nob

or you can just test a single file:

./nob test <FILE_BASENAME>

About

A C argument parser for basic usages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published