Git Product home page Git Product logo

cflag's Introduction

CFlag ⛳️

CFlag a simple CLI option, aka flag, header-only, stb-style library. It references the design of the Go flag module, but improves on it.

This library is currently a prototype will have breaking changes until v1.

Example

Since this library is in development, it's usage will change.

This is an example how the library currently works.

#include <stdio.h>

#define C_FLAG_IMPL
#include <cflag.h>


int main(int argc, char **argv) {
  // Initialize flag set.
  CFlagSet flags = cflag_from_args(argc, argv);

  // Initialize count to the default value.
  int count = 1;
  // Register count on the flag set on the CLI option "-c".
  cflag_int(&flags, &count, "-c");

  // Parse the CLI options and assign their values.
  int err = cflag_parse(&flags);
  if (err != 0) {
    return err;
  }

  // Use the option's value as if it is a normal variable.
  printf("Counting to %d\n", count);
  for (int idx = 0; idx < count; idx++) {
    printf("  %d\n", idx);
  }

  return 0;
}

Source.

TODOs

TODOs and ideas are either references in the source code, starting with "TODO:" and "FIXME:" or under this file.

License

This library is licensed under LGPL v3. Please take a look at the LICENSE

cflag's People

Watchers

 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.