{"id":28726874,"url":"https://github.com/docopt/docopt.coffee","last_synced_at":"2025-10-15T18:57:44.954Z","repository":{"id":3531541,"uuid":"4590978","full_name":"docopt/docopt.coffee","owner":"docopt","description":"docopt - A command line option parser that will make you smile.","archived":false,"fork":false,"pushed_at":"2019-03-29T12:54:47.000Z","size":252,"stargazers_count":147,"open_issues_count":16,"forks_count":26,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-12T09:47:52.817Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","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/docopt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-07T21:57:02.000Z","updated_at":"2024-09-22T14:48:02.000Z","dependencies_parsed_at":"2022-08-29T11:41:17.958Z","dependency_job_id":null,"html_url":"https://github.com/docopt/docopt.coffee","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/docopt/docopt.coffee","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docopt%2Fdocopt.coffee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docopt%2Fdocopt.coffee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docopt%2Fdocopt.coffee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docopt%2Fdocopt.coffee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/docopt","download_url":"https://codeload.github.com/docopt/docopt.coffee/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docopt%2Fdocopt.coffee/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259453470,"owners_count":22860083,"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":[],"created_at":"2025-06-15T13:09:27.026Z","updated_at":"2025-10-15T18:57:44.844Z","avatar_url":"https://github.com/docopt.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"`docopt` – command line option parser, that will make you smile\n===============================================================================\n\n\u003e [docopt](http://docopt.org/) is a language for description of command-line\n\u003e interfaces. This is `docopt` implementation in CoffeeScript, that could\n\u003e be used for server-side CoffeeScript and JavaScript programs.\n\nIsn't it awesome how modern command-line arguments parsers generate\nhelp message based on your code?!\n\nHell no!  You know what's awesome?  It's when the option parser *is* generated\nbased on the help message that you write yourself!  This way\nyou don't need to write this stupid repeatable parser-code, and instead can\nwrite a beautiful help message (the way you want it!), which adds readability\nto your code.\n\nNow you can write an awesome, readable, clean, DRY code like *that*:\n\n```coffeescript\ndoc = \"\"\"\nUsage:\n  quick_example.coffee tcp \u003chost\u003e \u003cport\u003e [--timeout=\u003cseconds\u003e]\n  quick_example.coffee serial \u003cport\u003e [--baud=9600] [--timeout=\u003cseconds\u003e]\n  quick_example.coffee -h | --help | --version\n\n\"\"\"\n{docopt} = require '../docopt'\n\nconsole.log docopt(doc, version: '0.1.1rc')\n```\n\nHell yeah! The option parser is generated based on `doc` string above, that you\npass to the `docopt` function.\n\nAPI `{docopt} = require 'docopt'`\n===============================================================================\n\n###`options = docopt(doc, {argv: process.argv[2..], help: true, version: null})`\n\n`docopt` takes 1 required and 3 optional keyword arguments:\n\n- `doc` should be a string with help message, written according to rules\nof [docopt language](http://docopt.org). Here is a quick example of such\na string:\n\n        Usage: your_program [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- `argv` is an optional argument vector; by default it is the argument vector\npassed to your program (`process.argv[2..]`). You can supply it with an array\nof strings (similar to `process.argv`) e.g. ['--verbose', '-o', 'hai.txt'].\n\n- `help`, by default `true`, specifies whether the parser should automatically\nprint the help message (supplied as `doc`) in case `-h` or `--help` options\nare encountered. After showing the usage-message, the program will terminate.\nIf you want to handle `-h` or `--help` options manually (as all other options),\nset `help=false`.\n\n- `version`, by default `null`, is an optional argument that specifies the\nversion 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,\ne.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 an Object with properties\n(giving long options precedence), e.g:\n\n    {'--timeout': '10',\n     '--baud': '4800',\n     '--version': false,\n     '--help': false,\n     '-h': false,\n     serial: true,\n     tcp: false,\n     '\u003chost\u003e': false,\n     '\u003cport\u003e': '/dev/ttyr01'}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocopt%2Fdocopt.coffee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdocopt%2Fdocopt.coffee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocopt%2Fdocopt.coffee/lists"}