Tiny command-line parser for C / C++

Build and test Scc Count Badge

tinyargs

Another commandline argument parser for C / C++.

This one is tiny, source only, and builds cleanly with -Wall -pedantic under C99 and C++11 on macOS, Linux and Windows.

See header file for reference docs.

Example use:

#include "args.h"
#include <stdio.h>

int main(int argc, const char** argv) {
    static OPTDEFS(opts,
                   INTOPT("blurgAmount", "9"),
                   FLOATOPT("fudgeRatio", "-2.33"),
                   STRINGOPT("trunkPrefix", "-=-"),
                   BOOLOPT("help"));

    if (!parseArgs(&argc, &argv, opts)) {
        printf("Invalid option \"%s\".\n\n", argv[argc]);
        printf(
            "Usage: %s [options] [args]\n\n"
            "Options:\n\n%s\n",
            argv[0],
            listOptions(opts));
        return 42;
    }

    printf("Will operate on: [\n");
    for (int i = 0; i < argc; i++) {
        printf("\t%s\n", argv[i]);
    }
    printf("]\n");

    printf(
        "with a blurgAmount of %d, "
        "a fudgeRatio of %f, "
        "using trunkPrefix: %s, "
        "%shelp requested.\n",
        getIntOption(opts, "blurgAmount"),
        getFloatOption(opts, "fudgeRatio"),
        getStringOption(opts, "trunkPrefix"),
        getBoolOption(opts, "help") ? "" : "no ");
}
$ ./example -fudgeRatio=3.14 -help A B C
Will operate on: [
	A
	B
	C
]
with a blurgAmount of 9, a fudgeRatio of 3.140000, using trunkPrefix: -=-, help requested.
$ ./example -notAnOption=66
Invalid option "-notAnOption=66".

Usage: ./example [options] [args]

Options:

-blurgAmount=<int>      (default=9)
-fudgeRatio=<float>     (default=-2.330000)
-trunkPrefix=<string>   (default="-=-")
-help
Similar Resources

A command-line tool to display colorful distro information.

A command-line tool to display colorful distro information.

sjfetch A command-line tool to display colorful distro information.

Apr 6, 2022

LwSHELL is lightweight, platform independent, command line shell for embedded systems.

LwSHELL is lightweight, platform independent, command line shell for embedded systems. It targets communication with embedded systems from remote terminal to quickly send commands and the retrieve data from the device.

Dec 25, 2022

Toybox: all-in-one Linux command line.

Toybox: all-in-one Linux command line.

Dec 27, 2022

Simple command line tool that processes image files using the FidelityFX Super Resolution (FSR) or Contrast Adaptive Sharpening (CAS) shader systems.

Simple command line tool that processes image files using the FidelityFX Super Resolution (FSR) or Contrast Adaptive Sharpening (CAS) shader systems.

Dec 12, 2022

Command-line flag parsing in C

flag.h Inspired by Go's flag module: https://pkg.go.dev/flag WARNING! The design of the library is not finished and may be a subject to change. Quick

Nov 10, 2022

A command line tool with no external dependencies to print information about an X server instance.

xinfo A command line tool with no external dependencies to print information about an X server instance. Building and running To build the code in thi

Jan 13, 2022

Windows command line program for Spleeter, written in pure C, no need of Python.

Windows command line program for Spleeter, written in pure C, no need of Python.

SpleeterMsvcExe is a Windows command line program for Spleeter, which can be used directly. It is written in pure C language, using ffmpeg to read and write audio files, and using Tensorflow C API to make use of Spleeter models. No need to install Python environment, and it does not contain anything related to Python.

Dec 5, 2022

easy to use, powerful & expressive command line argument parsing for modern C++ / single header / usage & doc generation

clipp - command line interfaces for modern C++ Easy to use, powerful and expressive command line argument handling for C++11/14/17 contained in a sing

Dec 29, 2022

Parse command line arguments by defining a struct

Parse command line arguments by defining a struct

Parse command line arguments by defining a struct Quick Start #include structopt/app.hpp struct Options { // positional argument // e.g., .

Dec 20, 2022
CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.
CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.

CLI11: Command line parser for C++11 What's new • Documentation • API Reference CLI11 is a command line parser for C++11 and beyond that provides a ri

Dec 30, 2022
Lightweight C++ command line option parser

Release versions Note that master is generally a work in progress, and you probably want to use a tagged release version. Version 3 breaking changes I

Dec 30, 2022
A simple to use, composable, command line parser for C++ 11 and beyond

Lyra A simple to use, composing, header only, command line arguments parser for C++ 11 and beyond. Obtain License Standards Stats Tests License Distri

Dec 22, 2022
led is a line-oriented text editor in command line
led is a line-oriented text editor in command line

led is a line-oriented text editor in command line. This editor is similar to the standard program on unix systems - GNU ed. But i'm not going to make an exact clone of that program, it's just a pet project.

Dec 27, 2022
udmp-parser: A Windows user minidump C++ parser library.
udmp-parser: A Windows user minidump C++ parser library.

udmp-parser: A Windows user minidump C++ parser library. This is a cross-platform (Windows / Linux / OSX / x86 / x64) C++ library that parses Windows

Dec 13, 2022
A library for interactive command line interfaces in modern C++
A library for interactive command line interfaces in modern C++

cli A cross-platform header only C++14 library for interactive command line interfaces (Cisco style) Features Header only Cross-platform (linux and wi

Dec 31, 2022
A single header C++ library for parsing command line arguments and options with minimal amount of code

Quick Arg Parser Tired of unwieldy tools like getopt or argp? Quick Arg Parser is a single header C++ library for parsing command line arguments

Dec 21, 2022
CLIp is a clipboard emulator for a command line interface written in 100% standard C only. Pipe to it to copy, pipe from it to paste.

CLIp v2 About CLIp is a powerful yet easy to use and minimal clipboard manager for a command line environment, with no dependencies or bloat. Usage Sy

Sep 18, 2021
pbr2gltf2 is a command line tool for converting PBR images to a glTF 2.0 material.
pbr2gltf2 is a command line tool for converting PBR images to a glTF 2.0 material.

pbr2gltf2 is a command line tool for converting PBR images to a glTF 2.0 material. The tool is detecting depending on the filename, which PBR information is stored. It swizzles the images and does reassign the channels to a glTF 2.0 image. The tool stores the images plus a minimal, valid glTF 2.0 file containing the required material, textures and images.

Jul 31, 2022
Dec 27, 2022