Skip to main content

docopt2ragel makes command line interface parsing easy!

docopt2ragel parses docopt USAGE text and outputs a Ragel finite state machine for parsing the CLI.

You can then use Ragel to output the finite state machine into C source code.

Example

Create a USAGE file using docopt’s declarative format. See below for example contents:

dq - a command line tool for duraqueue the dead simple queue

Usage:
  dq info <queue_file>
  dq --help

Options:
  -h --help  Prints a short usage summary.

Convert the USAGE file into a Ragel file:

docopt2ragel.py USAGE > usage.rl

Convert the Ragel file into a C file:

ragel usage.rl

Import the generated file into your source:

#include "usage.c"

int main(int argc, char **argv)
{
    int e;
    options_t opts;

    e = parse_options(argc, argv, &opts);
    if (-1 == e)
    {
        exit(-1);
    }

    void *qu = NULL;

    if (opts.help)
    {
        show_usage();
        exit(0);
    }
    else if (opts.info)
    {
        qu = dqueuer_open(opts.queue_file);
    }

    if (qu)
        printf("Item count: %d\n", dqueue_count(qu));

    return 1;
}

For real life examples see:

Metadata

Release files for docopt2ragel 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for docopt2ragel 0.1.4
File Size Uploaded Provenance Actions
docopt2ragel-0.1.4.tar.gz 4.9 kB Without provenance Details for docopt2ragel-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for docopt2ragel 0.1.4
File Interpreter ABI Platform Actions
docopt2ragel-0.1.4-py2.py3-none-any.whl Python 2, Python 3 none any Details for docopt2ragel-0.1.4-py2.py3-none-any.whl

Total release size: 11.8 kB

Release files / docopt2ragel-0.1.4.tar.gz

Download URL docopt2ragel-0.1.4.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
93583cc5e7d5b2e9170d4833bba0a1196531cf5995ea3d672ce5a15a4076e14f
BLAKE2b-256 checksum
How to use checksums
129f23bf9fa5eb0cf2c0299b6cb2731b61e4d77da40565d1e8799330942c740b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / docopt2ragel-0.1.4-py2.py3-none-any.whl

Download URL docopt2ragel-0.1.4-py2.py3-none-any.whl
Size 6.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0444717ef228fcd7e56768e2a13c0aedc7f5e8a610c71894b559ded7f57297c3
BLAKE2b-256 checksum
How to use checksums
d958a903f6787f1c54c769c0b3973580d88bf48a497f2cc3a0700294e8b18e3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for docopt2ragel 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page