C-code generator for docopt language
Note, at this point the code generator handles only options (positional arguments, commands and pattern matching will follow).
Step 1. Describe your CLI in docopt language
Naval Fate.
Usage:
naval_fate ship create <name>...
naval_fate ship <name> move <x> <y> [--speed=<kn>]
naval_fate ship shoot <x> <y>
naval_fate mine (set|remove) <x> <y> [--moored|--drifting]
naval_fate --help
naval_fate --version
Options:
-h --help Show this screen.
--version Show version.
--speed=<kn> Speed in knots [default: 10].
--moored Moored (anchored) mine.
--drifting Drifting mine.
Step 2. Generate the C code
$ python -m docopt_c -o docopt.c example.docopt
or by using pipe
$ cat example.docopt | python -m docopt_c > docopt.c
Step 3. Include the generated docopt.c into your program
#include <stdlib.h>
#include "docopt.c"
int main(int argc, char *argv[])
{
DocoptArgs args = docopt(argc, argv, /* help */ 1, /* version */ "2.0rc2");
printf("Commands\n");
printf(" mine == %s\n", args.mine ? "true" : "false");
printf(" move == %s\n", args.move ? "true" : "false");
printf(" create == %s\n", args.create ? "true" : "false");
printf(" remove == %s\n", args.remove ? "true" : "false");
printf(" set == %s\n", args.set ? "true" : "false");
printf(" ship == %s\n", args.ship ? "true" : "false");
printf(" shoot == %s\n", args.shoot ? "true" : "false");
printf("Arguments\n");
printf(" x == %s\n", args.x);
printf(" y == %s\n", args.y);
printf("Flags\n");
printf(" --drifting == %s\n", args.drifting ? "true" : "false");
printf(" --help == %s\n", args.help ? "true" : "false");
printf(" --moored == %s\n", args.moored ? "true" : "false");
printf(" --version == %s\n", args.version ? "true" : "false");
printf("Options\n");
printf(" --speed == %s\n", args.speed);
return EXIT_SUCCESS;
}
Step 4. Profit!
$ c99 example.c -o example.out
$ ./example.out mine --drifting --speed=20
Commands
mine == true
move == false
create == false
remove == false
set == false
ship == false
shoot == false
Arguments
x == (null)
y == (null)
Flags
--drifting == true
--help == false
--moored == false
--version == false
Options
--speed == 20
Development
See the Python version's page for more info on developing.
Metadata
Release files for docopt-c 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| docopt_c-0.0.3.tar.gz | 15.8 kB | Without provenance | Details for docopt_c-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| docopt_c-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for docopt_c-0.0.3-py3-none-any.whl |
Total release size: 40.1 kB
Release files / docopt_c-0.0.3.tar.gz
| Download URL | docopt_c-0.0.3.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e953bcc50920f313b73fd8b9a8ff70aeabd4c0d1a8d0b70764752f0ce0d05d4
|
|
BLAKE2b-256 checksum How to use checksums |
922f68a72a1c68d9c51cfc89db213ab011a3cbb2b65ec471ef9fd6a1ca478599
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Release files / docopt_c-0.0.3-py3-none-any.whl
| Download URL | docopt_c-0.0.3-py3-none-any.whl |
|---|---|
| Size | 24.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28561104e39a297d96f17ad27327630bb8902ba7c0747e14d40823f4e704d895
|
|
BLAKE2b-256 checksum How to use checksums |
a6b225081183291cbf777e6c7ae4a10d9f2872bd345bb078ccea7a703831ad98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Security for docopt-c 0.0.3
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.