{"id":15406767,"url":"https://github.com/dannyben/docopt_ng","last_synced_at":"2025-04-18T02:57:55.602Z","repository":{"id":65643132,"uuid":"596129011","full_name":"DannyBen/docopt_ng","owner":"DannyBen","description":"Parse command line arguments from nothing more than a usage message","archived":false,"fork":false,"pushed_at":"2024-04-13T06:13:56.000Z","size":127,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-06T05:19:34.634Z","etag":null,"topics":["docopt","docopt-ng","optparse","ruby","ruby-gem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DannyBen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-02-01T14:27:38.000Z","updated_at":"2024-02-26T15:50:45.000Z","dependencies_parsed_at":"2024-04-13T07:27:42.160Z","dependency_job_id":"231a2f39-4487-402d-8276-086fb72e7665","html_url":"https://github.com/DannyBen/docopt_ng","commit_stats":{"total_commits":82,"total_committers":9,"mean_commits":9.11111111111111,"dds":0.6951219512195121,"last_synced_commit":"ee72191f883e943d68048fc2ac36d3f1d116eb3f"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fdocopt_ng","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fdocopt_ng/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fdocopt_ng/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fdocopt_ng/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DannyBen","download_url":"https://codeload.github.com/DannyBen/docopt_ng/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":220053583,"owners_count":16588691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docopt","docopt-ng","optparse","ruby","ruby-gem"],"created_at":"2024-10-01T16:25:18.140Z","updated_at":"2024-10-17T12:22:43.862Z","avatar_url":"https://github.com/DannyBen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docopt – command line option parser, that will make you smile\n\n[![Gem Version](https://badge.fury.io/rb/docopt_ng.svg)](https://badge.fury.io/rb/docopt_ng)\n[![Build Status](https://github.com/DannyBen/docopt_ng/workflows/Test/badge.svg)](https://github.com/DannyBen/docopt_ng/actions?query=workflow%3ATest)\n[![Maintainability](https://api.codeclimate.com/v1/badges/31af96bab7913f71dc28/maintainability)](https://codeclimate.com/github/DannyBen/docopt_ng/maintainability)\n\n---\n\nThis is a detached fork of the original [docopt.rb](https://github.com/docopt/docopt.rb).\n\n- For a drop-in replacement, simply `require 'docopt_ng/docopt'`\n- Otherwise, use `require 'docopt_ng'` and `DocoptNG` instead of `Docopt`.\n\n---\n\nThis is the ruby port of [`docopt`](https://github.com/docopt/docopt),\nthe awesome option parser written originally in python.\n\nIsn't it awesome how `optparse` and `argparse` generate help messages\nbased on your code?!\n\n*Hell no!*  You know what's awesome?  It's when the option parser *is* generated\nbased on the beautiful help message that you write yourself!  This way\nyou don't need to write this stupid repeatable parser-code, and instead can\nwrite only the help message--*the way you want it*.\n\n`docopt` helps you create most beautiful command-line interfaces *easily*:\n\n```ruby\nrequire \"docopt_ng/docopt\"\n\ndoc = \u003c\u003cDOCOPT\nNaval Fate.\n\nUsage:\n  #{__FILE__} ship new \u003cname\u003e...\n  #{__FILE__} ship \u003cname\u003e move \u003cx\u003e \u003cy\u003e [--speed=\u003ckn\u003e]\n  #{__FILE__} ship shoot \u003cx\u003e \u003cy\u003e\n  #{__FILE__} mine (set|remove) \u003cx\u003e \u003cy\u003e [--moored|--drifting]\n  #{__FILE__} -h | --help\n  #{__FILE__} --version\n\nOptions:\n  -h --help     Show this screen.\n  --version     Show version.\n  --speed=\u003ckn\u003e  Speed in knots [default: 10].\n  --moored      Moored (anchored) mine.\n  --drifting    Drifting mine.\n\nDOCOPT\n\nbegin\n  pp Docopt.docopt(doc)\nrescue Docopt::Exit =\u003e e\n  puts e.message\n  exit e.exit_code\nend\n```\n\nBeat that! The option parser is generated based on the docstring above that is\npassed to `docopt` function.  `docopt` parses the usage pattern\n(`Usage: ...`) and option descriptions (lines starting with dash \"`-`\") and\nensures that the program invocation matches the usage pattern; it parses\noptions, arguments and commands based on that. The basic idea is that\n*a good help message has all necessary information in it to make a parser*.\n\n## Installation\n\n\n```shell\n$ gem install docopt_ng\n```\n\n\n## API\n\n`Docopt` takes 1 required and 1 optional argument:\n\n- `doc` should be a string that\n  describes **options** in a human-readable format, that will be parsed to create\n  the option parser.  The simple rules of how to write such a docstring\n  (in order to generate option parser from it successfully) are given in the next\n  section. Here is a quick example of such a string:\n\n        Usage: your_program.rb [options]\n\n        -h --help     Show this.\n        -v --verbose  Print more text.\n        --quiet       Print less text.\n        -o FILE       Specify output file [default: ./test.txt].\n\n  The optional second argument contains a hash of additional data to influence\n  docopt. The following keys are supported: \n\n- `help`, by default `true`, specifies whether the parser should automatically\n  print the usage-message (supplied as `doc`) in case `-h` or `--help` options\n  are encountered. After showing the usage-message, the program will terminate.\n  If you want to handle `-h` or `--help` options manually (as all other options),\n  set `help=false`.\n\n- `version`, by default `nil`, is an optional argument that specifies the\n  version of your program. If supplied, then, if the parser encounters\n  `--version` option, it will print the supplied version and terminate.\n  `version` could be any printable object, but most likely a string,\n  e.g. `'2.1.0rc1'`.\n\nNote, when `docopt` is set to automatically handle `-h`, `--help` and\n`--version` options, you still need to mention them in the options description\n(`doc`) for your users to know about them.\n\nThe **return** value is just a hash with options, arguments and commands,\nwith keys spelled exactly like in a help message\n(long versions of options are given priority). For example, if you invoke\nthe top example as:\n\n```\n$ naval_fate.rb ship Guardian move 100 150 --speed=15\n```\n\nthe return hash will be::\n\n```ruby\n{\n  \"ship\" =\u003e true,\n  \"new\" =\u003e false,\n  \"\u003cname\u003e\" =\u003e [\"Guardian\"],\n  \"move\" =\u003e true,\n  \"\u003cx\u003e\" =\u003e \"100\",\n  \"\u003cy\u003e\" =\u003e \"150\",\n  \"--speed\" =\u003e \"15\",\n  \"shoot\" =\u003e false,\n  \"mine\" =\u003e false,\n  \"set\" =\u003e false,\n  \"remove\" =\u003e false,\n  \"--moored\" =\u003e false,\n  \"--drifting\" =\u003e false,\n  \"--help\" =\u003e false,\n  \"--version\" =\u003e false\n}\n```\n\n## Help message format\n\nThis port of docopt follows the docopt help message format.\nYou can find more details at\n[official docopt git repo](https://github.com/docopt/docopt#help-message-format)\n\n\n## Examples\n\nThe [examples directory](examples) contains several examples which cover most\naspects of the docopt functionality. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fdocopt_ng","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdannyben%2Fdocopt_ng","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fdocopt_ng/lists"}