Git Product home page Git Product logo

argo's Introduction

Argo

A simple command line argument parsing header file. It is based on argparse, but made to be a header-only library. The library was designed to be as simple to use as possible. The code isn't the nicest at the moment, but I plan to clean it up over time.

Arguments are specified in a number of ways resembling GNU's getop,
shorthand: -f<value>, -f <value>
full name: --fullName=<value>, --fullName <value>

Types of arguments:

  • Flag: takes int pointer, no input value, will always set the pointer to either 1 or 0, can specify multiple flags in shorthand i.e. -abc (sets flags a, b, and c)
  • Int: takes int pointer, receives valid atoi strings, will not affect its pointer if the argument is not passed
  • Char: takes char pointer, receives first character of inputted string, will not affect its pointer if the argument is not passed
  • Double: takes double pointer, receives valid atof strings, will not affect its pointer if the argument is not passed
  • String: takes char* pointer, receives strings, will not affect its pointer if the argument is not passed

Usage

Include the header file argo.h then create an array of argo_args and finally call the function argo_parse and boom! You're done!

argo_parse is defined as: int argo_parse(char ***leftover, int argc, char **argv, argo_arg *list)

  • leftover: pointer to a char**, will be set to a newly allocated array of strings containing all un-parsed arguments. You can set this to NULL if you do not want anything to be allocated.
  • argc: int, argument from main function unaltered.
  • argv: char**, argument from main function unaltered, will remain unaltered.
  • list: argo_arg*, array of arguments to parse for, will remain unaltered.

return: int, size of the array of leftovers If it returns 0, leftovers will be set to NULL. If it returns -1 it means that the allocation has failed, but parsing was successful; do with that knowledge as you will.

I've added an example program showing the most basic usage of the library with descriptive comments in examples/example.c

argo's People

Contributors

8bitslime avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.