Giter Site home page Giter Site logo

optz's Introduction

optz

Easy command parser written in C with ZERO memory waste.

Introduction

This project aims to provide a simple option parser for development of cli applications.

The main requirement is to keep the memory usage as low as possible, with zero waste, in order to make it suitable for embedded projects.

Example

[-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p] [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]] [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--] [...]

int asc_order = 1;
int ls = MAX_LENGTH, ln = MAX_LENGTH;
int scores[MAX_LENGTH];
int round = 1;
int verbose;
int hightlight = -1;

char * judge;
char * names[MAX_LENGTH];
char version[]  = "1.2.1";

optz options[] = {
  { "-v", "--version" , "Output program version"                      , OPTZ_CALLBACK, &optz_version_cb, &version },
  { "-h", "--help"    , "Display the help message."                   , OPTZ_CALLBACK, &optz_help_cb },
  { "-a", "--asc"     , "Display scores in the ascending order."      , OPTZ_BOOLEAN , &verbose },
  { "-d", "--desc"    , "Display scores in the descending order."     , OPTZ_NBOOLEAN, &asc_order },
  { "-j", "--judge  <NAME>"      , "Name of the judge"                , OPTZ_REQUIRED & OPTZ_STRING, &judge },
  { "-s", "--scores <S1,S2,...>" , "Comma separeted list of integers" , OPTZ_REQUIRED },
  { "-n", "--names  <N1,N2,...>" , "Comma separeted list of names"    , OPTZ_REQUIRED }, 
  { "-H", "--highlight [N]"      , "Highlight the N first winners"    , OPTZ_INTEGER , &highlight }, 
}

optz_integer_list(&options[4], &scores, &ls);
optz_string_list(&options[5], &names, &ln);

optz's People

Contributors

abravalheri avatar

Watchers

 avatar James Cloos 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.