GithubHelp home page GithubHelp logo

vstan02 / conix Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 228 KB

A library for easy handling of command line options

Home Page: https://vstan02.github.io/conix/

License: GNU General Public License v3.0

CMake 9.70% C 90.30%
cli library c command-line argument-handler conix handling getopt

conix's Introduction

Conix

A library for easy handling of command line options

Version: v1.0.0 License: GPL v3

Contents

Usage

Here is an example of usage (for the full version see demo/main.c file):

// Creating an new cli instance:
cnx_cli_t* cli = cnx_cli_init((cnx_app_t) { "my_app", "2.8.1" });

// Adding some options for handling:
cnx_cli_add(cli, 5, (cnx_option_t[]) {
	// cnx_option_t -> { name, description, handler, payload }.
	{ "-a, --about", "Display something", about_option, NULL },
	{ "-p, --print", "Display passed arguments", print_args_option, NULL },
	
	// Handlers for "-v, --version" and "-h, --help" are added
	// by default, but you can add your own handlers for them.
	{ "-v, --version", "Display version", version_option, NULL },
	
	// Handler for "--default" is called when are no arguments passed.
	{ "--default", "Default option", index_option, NULL },
	
	// Handler for "*" is called when is passed an unknown cli option.
	// By default it has the same handler as the "-h, --help" option.
	{ "*", NULL, not_found_option, NULL }
});

// Running for some command line arguments:
cnx_cli_run(cli, argc, argv);

// Destroying the instance:
cnx_cli_free(cli);

After project building you can run this example as you can see here.

Also, you can see xcalc - an real example of using Conix.

Building and Installation

Dependencies

  • C compiler (gcc, clang, etc...)
  • cmake (>= 3.16)

These packages can usually be installed through your distributions package manager.

Building the project

To build the project, we first need to create a separate build directory:

mkdir build

Now that we've created our build directory (assuming it's created in the project root), we can cd into it and run cmake and pass the parent directory path to it, which is where the CMakeLists.txt file is located:

cd build
cmake ..

Once cmake is done generating makefiles, we can build the library by running make inside our build directory:

make

Running demo

./demo

Installing

To install the library run:

sudo make install

By default the libraries and headers will be installed in /usr/local/lib and /usr/local/include directories.

License

Conix is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. For more details, see LICENSE file.

Contributing

Contributions are welcome. If you have a feature request, or have found a bug, feel free to open a new issue. If you wish to contribute code, see CONTRIBUTING.md for more details.

conix's People

Contributors

vstan02 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

conix's Issues

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.