Skip to content
/ argparse Public

Command-line arguments parsing library.

License

Notifications You must be signed in to change notification settings

cofyc/argparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

682d452 · Jul 15, 2024
Dec 13, 2021
Feb 11, 2022
Feb 10, 2022
Jul 13, 2024
Nov 26, 2018
Jul 16, 2013
Feb 10, 2022
Nov 23, 2018
Feb 10, 2022
Jul 2, 2024
Feb 11, 2022

Repository files navigation

argparse

Build Status

argparse - A command line arguments parsing library in C (compatible with C++).

Description

This module is inspired by parse-options.c (git) and python's argparse module.

Arguments parsing is common task in cli program, but traditional getopt libraries are not easy to use. This library provides high-level arguments parsing solutions.

The program defines what arguments it requires, and argparse will figure out how to parse those out of argc and argv, it also automatically generates help and usage messages and issues errors when users give the program invalid arguments.

Features

  • handles both optional and positional arguments
  • produces highly informative usage messages
  • issues errors when given invalid arguments

There are basically three types of options:

  • boolean options
  • options with mandatory argument
  • options with optional argument

There are basically two forms of options:

  • short option consist of one dash (-) and one alphanumeric character.
  • long option begin with two dashes (--) and some alphanumeric characters.

Short options may be bundled, e.g. -a -b can be specified as -ab.

Options are case-sensitive.

Options and non-option arguments can clearly be separated using the -- option.

Examples