ProductPromotion
Logo

C Programming

made by https://0x3d.site

GitHub - docopt/docopt.c: C-code generator for docopt language.
C-code generator for docopt language. Contribute to docopt/docopt.c development by creating an account on GitHub.
Visit Site

GitHub - docopt/docopt.c: C-code generator for docopt language.

GitHub - docopt/docopt.c: C-code generator for docopt language.

C-code generator for docopt language

License PyPi publish PyPi: release

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 "docopt.h"

int main(int argc, char *argv[])
{
    struct DocoptArgs args = docopt(argc, argv, /* help */ 1, /* version */ "2.0rc2");

    puts("Commands");
    printf("\tmine == %s\n", args.mine ? "true" : "false");
    printf("\tmove == %s\n", args.move ? "true" : "false");
    printf("\tcreate == %s\n", args.create ? "true" : "false");
    printf("\tremove == %s\n", args.remove ? "true" : "false");
    printf("\tset == %s\n", args.set ? "true" : "false");
    printf("\tship == %s\n", args.ship ? "true" : "false");
    printf("\tshoot == %s\n", args.shoot ? "true" : "false");
    puts("Arguments");
    printf("\tx == %s\n", args.x);
    printf("\ty == %s\n", args.y);
    puts("Flags");
    printf("\t--drifting == %s\n", args.drifting ? "true" : "false");
    printf("\t--help == %s\n", args.help ? "true" : "false");
    printf("\t--moored == %s\n", args.moored ? "true" : "false");
    printf("\t--version == %s\n", args.version ? "true" : "false");
    puts("Options");
    printf("\t--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.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory