You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"examples","path":"examples","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"CMakeLists.txt","path":"CMakeLists.txt","contentType":"file"},{"name":"LICENSE-Boost-1.0","path":"LICENSE-Boost-1.0","contentType":"file"},{"name":"LICENSE-MIT","path":"LICENSE-MIT","contentType":"file"},{"name":"README.rst","path":"README.rst","contentType":"file"},{"name":"docopt-config.cmake","path":"docopt-config.cmake","contentType":"file"},{"name":"docopt.cpp","path":"docopt.cpp","contentType":"file"},{"name":"docopt.h","path":"docopt.h","contentType":"file"},{"name":"docopt_private.h","path":"docopt_private.h","contentType":"file"},{"name":"docopt_util.h","path":"docopt_util.h","contentType":"file"},{"name":"docopt_value.h","path":"docopt_value.h","contentType":"file"},{"name":"main.cpp","path":"main.cpp","contentType":"file"},{"name":"run_testcase.cpp","path":"run_testcase.cpp","contentType":"file"},{"name":"run_tests.py","path":"run_tests.py","contentType":"file"},{"name":"testcases.docopt","path":"testcases.docopt","contentType":"file"}],"totalCount":17}},"fileTreeProcessingTime":3.088681,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":66108518,"defaultBranch":"master","name":"docopt.cpp","ownerLogin":"OSVR","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2016-08-19T19:53:10.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/10343613?v=4","public":true,"private":false,"isOrgOwned":true},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"master","listCacheKey":"v0:1471637709.0","canEdit":false,"refType":"branch","currentOid":"0237c9adc88b1165d77b8303b1fb70d676d4d11e"},"path":"README.rst","currentUser":null,"blob":{"rawLines":null,"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/OSVR/docopt.cpp/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"README.rst","displayUrl":"https://github.com/OSVR/docopt.cpp/blob/master/README.rst?raw=true","headerInfo":{"blobSize":"16.9 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"b7e871e","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2FOSVR%2Fdocopt.cpp%2Fblob%2Fmaster%2FREADME.rst","isCSV":false,"isRichtext":true,"toc":[{"level":1,"text":"docopt.cpp: A C++11 Port","anchor":"docoptcpp-a-c11-port","htmlText":"docopt.cpp: A C++11 Port"},{"level":2,"text":"docopt creates beautiful command-line interfaces","anchor":"docopt-creates-beautiful-command-line-interfaces","htmlText":"docopt creates beautiful command-line interfaces"},{"level":2,"text":"C++11 port details","anchor":"c11-port-details","htmlText":"C++11 port details"},{"level":2,"text":"API","anchor":"api","htmlText":"API"},{"level":2,"text":"Help message format","anchor":"help-message-format","htmlText":"Help message format"},{"level":2,"text":"Usage pattern format","anchor":"usage-pattern-format","htmlText":"Usage pattern format"},{"level":2,"text":"Option descriptions format","anchor":"option-descriptions-format","htmlText":"Option descriptions format"},{"level":2,"text":"Examples","anchor":"examples","htmlText":"Examples"},{"level":2,"text":"Subparsers, multi-level help and huge applications (like git)","anchor":"subparsers-multi-level-help-and-huge-applications-like-git","htmlText":"Subparsers, multi-level help and huge applications (like git)"},{"level":2,"text":"Compiling the example / Running the tests","anchor":"compiling-the-example--running-the-tests","htmlText":"Compiling the example / Running the tests"},{"level":2,"text":"Development","anchor":"development","htmlText":"Development"},{"level":2,"text":"Changelog","anchor":"changelog","htmlText":"Changelog"}],"lineInfo":{"truncatedLoc":"444","truncatedSloc":"339"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"reStructuredText","languageID":419,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/OSVR/docopt.cpp/blob/master/README.rst","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/OSVR/docopt.cpp/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/OSVR/docopt.cpp/raw/refs/heads/master/README.rst","renderImageOrRaw":false,"richText":"\u003carticle class=\"markdown-body entry-content container-lg\" itemprop=\"text\"\u003e\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch1 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003e\u003ccode\u003edocopt.cpp\u003c/code\u003e: A C++11 Port\u003c/h1\u003e\u003ca id=\"user-content-docoptcpp-a-c11-port\" class=\"anchor\" aria-label=\"Permalink: docopt.cpp: A C++11 Port\" href=\"#docoptcpp-a-c11-port\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003ca name=\"user-content-docopt-creates-beautiful-command-line-interfaces\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003edocopt creates \u003cem\u003ebeautiful\u003c/em\u003e command-line interfaces\u003c/h2\u003e\u003ca id=\"user-content-docopt-creates-beautiful-command-line-interfaces\" class=\"anchor\" aria-label=\"Permalink: docopt creates beautiful command-line interfaces\" href=\"#docopt-creates-beautiful-command-line-interfaces\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIsn't it awesome how \u003ccode\u003egetopt\u003c/code\u003e (and \u003ccode\u003eboost::program_options\u003c/code\u003e for you fancy\nfolk!) generate help messages based on your code?! These timeless functions\nhave been around for decades and have proven we don't need anything better, right?\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cem\u003eHell no!\u003c/em\u003e You know what's awesome? It's when the option parser \u003cem\u003eis\u003c/em\u003e\ngenerated based on the beautiful help message that you write yourself!\nThis way you don't need to write this stupid repeatable parser-code,\nand instead can write only the help message--\u003cem\u003ethe way you want it\u003c/em\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003edocopt\u003c/strong\u003e helps you create most beautiful command-line interfaces\n\u003cem\u003eeasily\u003c/em\u003e:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-c++ notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"#include \u0026quot;docopt.h\u0026quot;\n\n#include \u0026lt;iostream\u0026gt;\n\nstatic const char USAGE[] =\nR\u0026quot;(Naval Fate.\n\n Usage:\n naval_fate ship new \u0026lt;name\u0026gt;...\n naval_fate ship \u0026lt;name\u0026gt; move \u0026lt;x\u0026gt; \u0026lt;y\u0026gt; [--speed=\u0026lt;kn\u0026gt;]\n naval_fate ship shoot \u0026lt;x\u0026gt; \u0026lt;y\u0026gt;\n naval_fate mine (set|remove) \u0026lt;x\u0026gt; \u0026lt;y\u0026gt; [--moored | --drifting]\n naval_fate (-h | --help)\n naval_fate --version\n\n Options:\n -h --help Show this screen.\n --version Show version.\n --speed=\u0026lt;kn\u0026gt; Speed in knots [default: 10].\n --moored Moored (anchored) mine.\n --drifting Drifting mine.\n)\u0026quot;;\n\nint main(int argc, const char** argv)\n{\n std::map\u0026lt;std::string, docopt::value\u0026gt; args\n = docopt::docopt(USAGE,\n { argv + 1, argv + argc },\n true, // show help if requested\n \u0026quot;Naval Fate 2.0\u0026quot;); // version string\n\n for(auto const\u0026amp; arg : args) {\n std::cout \u0026lt;\u0026lt; arg.first \u0026lt;\u0026lt; arg.second \u0026lt;\u0026lt; std::endl;\n }\n\n return 0;\n}\"\u003e\u003cpre\u003e#\u003cspan class=\"pl-k\"\u003einclude\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003edocopt.h\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003e\u003c/span\u003e\n\n#\u003cspan class=\"pl-k\"\u003einclude\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\u0026lt;\u003c/span\u003eiostream\u003cspan class=\"pl-pds\"\u003e\u0026gt;\u003c/span\u003e\u003c/span\u003e\n\n\u003cspan class=\"pl-k\"\u003estatic\u003c/span\u003e \u003cspan class=\"pl-k\"\u003econst\u003c/span\u003e \u003cspan class=\"pl-k\"\u003echar\u003c/span\u003e USAGE[] =\n\u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003eR\"(\u003c/span\u003eNaval Fate.\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e Usage:\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e naval_fate ship new \u0026lt;name\u0026gt;...\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e naval_fate ship \u0026lt;name\u0026gt; move \u0026lt;x\u0026gt; \u0026lt;y\u0026gt; [--speed=\u0026lt;kn\u0026gt;]\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e naval_fate ship shoot \u0026lt;x\u0026gt; \u0026lt;y\u0026gt;\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e naval_fate mine (set|remove) \u0026lt;x\u0026gt; \u0026lt;y\u0026gt; [--moored | --drifting]\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e naval_fate (-h | --help)\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e naval_fate --version\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e Options:\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e -h --help Show this screen.\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e --version Show version.\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e --speed=\u0026lt;kn\u0026gt; Speed in knots [default: 10].\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e --moored Moored (anchored) mine.\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e --drifting Drifting mine.\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e)\"\u003c/span\u003e\u003c/span\u003e;\n\n\u003cspan class=\"pl-k\"\u003eint\u003c/span\u003e \u003cspan class=\"pl-en\"\u003emain\u003c/span\u003e(\u003cspan class=\"pl-k\"\u003eint\u003c/span\u003e argc, \u003cspan class=\"pl-k\"\u003econst\u003c/span\u003e \u003cspan class=\"pl-k\"\u003echar\u003c/span\u003e** argv)\n{\n std::map\u0026lt;std::string, docopt::value\u0026gt; args\n = \u003cspan class=\"pl-c1\"\u003edocopt::docopt\u003c/span\u003e(USAGE,\n { argv + \u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e, argv + argc },\n \u003cspan class=\"pl-c1\"\u003etrue\u003c/span\u003e, \u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e//\u003c/span\u003e show help if requested\u003c/span\u003e\n \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003eNaval Fate 2.0\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003e\u003c/span\u003e); \u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e//\u003c/span\u003e version string\u003c/span\u003e\n\n \u003cspan class=\"pl-k\"\u003efor\u003c/span\u003e(\u003cspan class=\"pl-k\"\u003eauto\u003c/span\u003e \u003cspan class=\"pl-k\"\u003econst\u003c/span\u003e\u0026amp; arg : args) {\n std::cout \u0026lt;\u0026lt; arg.\u003cspan class=\"pl-smi\"\u003efirst\u003c/span\u003e \u0026lt;\u0026lt; arg.\u003cspan class=\"pl-smi\"\u003esecond\u003c/span\u003e \u0026lt;\u0026lt; std::endl;\n }\n\n \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e;\n}\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eBeat that! The option parser is generated based on the docstring above\nthat is passed to \u003ccode\u003edocopt::docopt\u003c/code\u003e function. \u003ccode\u003edocopt\u003c/code\u003e parses the usage\npattern (\u003ccode\u003e\"Usage: ...\"\u003c/code\u003e) and option descriptions (lines starting\nwith dash \"\u003ccode\u003e-\u003c/code\u003e\") and ensures that the program invocation matches the\nusage pattern; it parses options, arguments and commands based on\nthat. The basic idea is that \u003cem\u003ea good help message has all necessary\ninformation in it to make a parser\u003c/em\u003e.\u003c/p\u003e\n\u003ca name=\"user-content-c-11-port-details\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eC++11 port details\u003c/h2\u003e\u003ca id=\"user-content-c11-port-details\" class=\"anchor\" aria-label=\"Permalink: C++11 port details\" href=\"#c11-port-details\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis is a port of the \u003ccode\u003edocopt.py\u003c/code\u003e module (\u003ca href=\"https://github.com/docopt/docopt\"\u003ehttps://github.com/docopt/docopt\u003c/a\u003e),\nand we have tried to maintain full feature parity (and code structure) as the\noriginal.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis port is written in C++11 and also requires a good C++11 standard library\n(in particular, one with \u003ccode\u003eregex\u003c/code\u003e support). The following compilers are known\nto work with docopt:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eClang 3.3 and later\u003c/li\u003e\n\u003cli\u003eGCC 4.9\u003c/li\u003e\n\u003cli\u003eVisual C++ 2015 RC\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eGCC-4.8 can work, but the std::regex module needs to be replaced with \u003ccode\u003eBoost.Regex\u003c/code\u003e.\nIn that case, you will need to define \u003ccode\u003eDOCTOPT_USE_BOOST_REGEX\u003c/code\u003e when compiling\ndocopt, and link your code with the appropriated Boost libraries. A relativley\nrecent version of Boost is needed: 1.55 works, but 1.46 does not for example.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis port is licensed under the MIT license, just like the original module.\nHowever, we are also dual-licensing this code under the Boost License, version 1.0,\nas this is a popular C++ license. The licenses are similar and you are free to\nuse this code under the terms of either license.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe differences from the Python port are:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003ethe addition of a \u003ccode\u003edocopt_parse\u003c/code\u003e function, which does not terminate\nthe program on error\u003c/li\u003e\n\u003cli\u003ea \u003ccode\u003edocopt::value\u003c/code\u003e type to hold the various value types that can be parsed.\nWe considered using boost::variant, but it seems better to have no external\ndependencies (beyond a good STL).\u003c/li\u003e\n\u003cli\u003ebecause C++ is statically-typed and Python is not, we had to make some\nchanges to the interfaces of the internal parse tree types.\u003c/li\u003e\n\u003cli\u003ebecause \u003ccode\u003estd::regex\u003c/code\u003e does not have an equivalent to Python's regex.split,\nsome of the regex's had to be restructured and additional loops used.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-api\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAPI\u003c/h2\u003e\u003ca id=\"user-content-api\" class=\"anchor\" aria-label=\"Permalink: API\" href=\"#api\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdiv class=\"highlight highlight-source-c++ notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"docopt::docopt(doc, argv, help /* =true */, version /* =\u0026quot;\u0026quot; */, options_first /* =false */)\"\u003e\u003cpre\u003e\u003cspan class=\"pl-en\"\u003edocopt::docopt\u003c/span\u003e(doc, argv, help \u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e/*\u003c/span\u003e =true \u003cspan class=\"pl-c\"\u003e*/\u003c/span\u003e\u003c/span\u003e, version \u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e/*\u003c/span\u003e =\"\" \u003cspan class=\"pl-c\"\u003e*/\u003c/span\u003e\u003c/span\u003e, options_first \u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e/*\u003c/span\u003e =false \u003cspan class=\"pl-c\"\u003e*/\u003c/span\u003e\u003c/span\u003e)\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003edocopt\u003c/code\u003e takes 2 required and 3 optional arguments:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003edoc\u003c/code\u003e is a string that contains a \u003cstrong\u003ehelp message\u003c/strong\u003e that will be parsed to\ncreate the option parser. The simple rules of how to write such a\nhelp message are given in next sections. Here is a quick example of\nsuch a string (note that this example uses the \"raw string literal\" feature\nthat was added to C++11):\u003c/li\u003e\n\u003c/ul\u003e\n\u003cdiv class=\"highlight highlight-source-c++ notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"R\u0026quot;(Usage: my_program [-hso FILE] [--quiet | --verbose] [INPUT ...]\n\n-h --help show this\n-s --sorted sorted output\n-o FILE specify output file [default: ./test.txt]\n--quiet print less text\n--verbose print more text\n)\u0026quot;\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003eR\"(\u003c/span\u003eUsage: my_program [-hso FILE] [--quiet | --verbose] [INPUT ...]\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e-h --help show this\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e-s --sorted sorted output\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e-o FILE specify output file [default: ./test.txt]\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e--quiet print less text\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e--verbose print more text\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e)\"\u003c/span\u003e\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003e\u003ccode\u003eargv\u003c/code\u003e is a vector of strings representing the args passed. Although\nmain usually takes a \u003ccode\u003e(int argc, const char** argv)\u003c/code\u003e pair, you can\npass the value \u003ccode\u003e{argv+1, argv+argc}\u003c/code\u003e to generate the vector automatically.\n(Note we skip the argv[0] argument!) Alternatively you can supply a list of\nstrings like \u003ccode\u003e{ \"--verbose\", \"-o\", \"hai.txt\" }\u003c/code\u003e.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003e\u003ccode\u003ehelp\u003c/code\u003e, by default \u003ccode\u003etrue\u003c/code\u003e, specifies whether the parser should\nautomatically print the help message (supplied as \u003ccode\u003edoc\u003c/code\u003e) and\nterminate, in case \u003ccode\u003e-h\u003c/code\u003e or \u003ccode\u003e--help\u003c/code\u003e option is encountered\n(options should exist in usage pattern, more on that below). If you\nwant to handle \u003ccode\u003e-h\u003c/code\u003e or \u003ccode\u003e--help\u003c/code\u003e options manually (as other\noptions), set \u003ccode\u003ehelp=false\u003c/code\u003e.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003e\u003ccode\u003eversion\u003c/code\u003e, by default empty, is an optional argument that\nspecifies the version of your program. If supplied, then, (assuming\n\u003ccode\u003e--version\u003c/code\u003e option is mentioned in usage pattern) when parser\nencounters the \u003ccode\u003e--version\u003c/code\u003e option, it will print the supplied\nversion and terminate. \u003ccode\u003eversion\u003c/code\u003e could be any printable object,\nbut most likely a string, e.g. \u003ccode\u003e\"2.1.0rc1\"\u003c/code\u003e.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp dir=\"auto\"\u003eNote, when \u003ccode\u003edocopt\u003c/code\u003e is set to automatically handle \u003ccode\u003e-h\u003c/code\u003e,\n\u003ccode\u003e--help\u003c/code\u003e and \u003ccode\u003e--version\u003c/code\u003e options, you still need to mention\nthem in usage pattern for this to work (also so your users to\nknow about them!)\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003e\u003ccode\u003eoptions_first\u003c/code\u003e, by default \u003ccode\u003efalse\u003c/code\u003e. If set to \u003ccode\u003etrue\u003c/code\u003e will\ndisallow mixing options and positional argument. I.e. after first\npositional argument, all arguments will be interpreted as positional\neven if the look like options. This can be used for strict\ncompatibility with POSIX, or if you want to dispatch your arguments\nto other programs.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eThe \u003cstrong\u003ereturn\u003c/strong\u003e value is a \u003ccode\u003emap\u0026lt;string, docopt::value\u0026gt;\u003c/code\u003e with options,\narguments and commands as keys, spelled exactly like in your help message.\nLong versions of options are given priority. For example, if you invoke the\ntop example as:\u003c/p\u003e\n\u003cpre\u003enaval_fate ship Guardian move 100 150 --speed=15\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003ethe return dictionary will be:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"{\u0026quot;--drifting\u0026quot;: false, \u0026quot;mine\u0026quot;: false,\n \u0026quot;--help\u0026quot;: false, \u0026quot;move\u0026quot;: true,\n \u0026quot;--moored\u0026quot;: false, \u0026quot;new\u0026quot;: false,\n \u0026quot;--speed\u0026quot;: \u0026quot;15\u0026quot;, \u0026quot;remove\u0026quot;: false,\n \u0026quot;--version\u0026quot;: false, \u0026quot;set\u0026quot;: false,\n \u0026quot;\u0026lt;name\u0026gt;\u0026quot;: [\u0026quot;Guardian\u0026quot;], \u0026quot;ship\u0026quot;: true,\n \u0026quot;\u0026lt;x\u0026gt;\u0026quot;: \u0026quot;100\u0026quot;, \u0026quot;shoot\u0026quot;: false,\n \u0026quot;\u0026lt;y\u0026gt;\u0026quot;: \u0026quot;150\u0026quot;}\"\u003e\u003cpre\u003e{\u003cspan class=\"pl-s\"\u003e\"--drifting\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003efalse\u003c/span\u003e, \u003cspan class=\"pl-s\"\u003e\"mine\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003efalse\u003c/span\u003e,\n \u003cspan class=\"pl-s\"\u003e\"--help\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003efalse\u003c/span\u003e, \u003cspan class=\"pl-s\"\u003e\"move\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003etrue\u003c/span\u003e,\n \u003cspan class=\"pl-s\"\u003e\"--moored\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003efalse\u003c/span\u003e, \u003cspan class=\"pl-s\"\u003e\"new\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003efalse\u003c/span\u003e,\n \u003cspan class=\"pl-s\"\u003e\"--speed\"\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"15\"\u003c/span\u003e, \u003cspan class=\"pl-s\"\u003e\"remove\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003efalse\u003c/span\u003e,\n \u003cspan class=\"pl-s\"\u003e\"--version\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003efalse\u003c/span\u003e, \u003cspan class=\"pl-s\"\u003e\"set\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003efalse\u003c/span\u003e,\n \u003cspan class=\"pl-s\"\u003e\"\u0026lt;name\u0026gt;\"\u003c/span\u003e: [\u003cspan class=\"pl-s\"\u003e\"Guardian\"\u003c/span\u003e], \u003cspan class=\"pl-s\"\u003e\"ship\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003etrue\u003c/span\u003e,\n \u003cspan class=\"pl-s\"\u003e\"\u0026lt;x\u0026gt;\"\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"100\"\u003c/span\u003e, \u003cspan class=\"pl-s\"\u003e\"shoot\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003efalse\u003c/span\u003e,\n \u003cspan class=\"pl-s\"\u003e\"\u0026lt;y\u0026gt;\"\u003c/span\u003e: \u003cspan class=\"pl-s\"\u003e\"150\"\u003c/span\u003e}\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIf any parsing error (in either the usage, or due to incorrect user inputs) is\nencountered, the program will exit with exit code -1.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eNote that there is another function that does not exit on error, and instead will\npropogate an exception that you can catch and process as you like. See the docopt.h file\nfor information on the exceptions and usage:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-c++ notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"docopt::docopt_parse(doc, argv, help /* =true */, version /* =true */, options_first /* =false)\"\u003e\u003cpre\u003e\u003cspan class=\"pl-en\"\u003edocopt::docopt_parse\u003c/span\u003e(doc, argv, help \u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e/*\u003c/span\u003e =true \u003cspan class=\"pl-c\"\u003e*/\u003c/span\u003e\u003c/span\u003e, version \u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e/*\u003c/span\u003e =true \u003cspan class=\"pl-c\"\u003e*/\u003c/span\u003e\u003c/span\u003e, options_first \u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e/*\u003c/span\u003e =false)\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003ca name=\"user-content-help-message-format\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eHelp message format\u003c/h2\u003e\u003ca id=\"user-content-help-message-format\" class=\"anchor\" aria-label=\"Permalink: Help message format\" href=\"#help-message-format\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eHelp message consists of 2 parts:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eUsage pattern, e.g.:\u003c/p\u003e\n\u003cpre\u003eUsage: my_program [-hso FILE] [--quiet | --verbose] [INPUT ...]\n\u003c/pre\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eOption descriptions, e.g.:\u003c/p\u003e\n\u003cpre\u003e-h --help show this\n-s --sorted sorted output\n-o FILE specify output file [default: ./test.txt]\n--quiet print less text\n--verbose print more text\n\u003c/pre\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eTheir format is described below; other text is ignored.\u003c/p\u003e\n\u003ca name=\"user-content-usage-pattern-format\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUsage pattern format\u003c/h2\u003e\u003ca id=\"user-content-usage-pattern-format\" class=\"anchor\" aria-label=\"Permalink: Usage pattern format\" href=\"#usage-pattern-format\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eUsage pattern\u003c/strong\u003e is a substring of \u003ccode\u003edoc\u003c/code\u003e that starts with\n\u003ccode\u003eusage:\u003c/code\u003e (case \u003cem\u003einsensitive\u003c/em\u003e) and ends with a \u003cem\u003evisibly\u003c/em\u003e empty line.\nMinimum example:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"\u0026quot;\u0026quot;\u0026quot;Usage: my_program\n\n\u0026quot;\u0026quot;\u0026quot;\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s\"\u003e\"\"\"Usage: my_program\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e\"\"\"\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"a
7D6C
uto\"\u003eThe first word after \u003ccode\u003eusage:\u003c/code\u003e is interpreted as your program's name.\nYou can specify your program's name several times to signify several\nexclusive patterns:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"\u0026quot;\u0026quot;\u0026quot;Usage: my_program FILE\n my_program COUNT FILE\n\n\u0026quot;\u0026quot;\u0026quot;\"\u003e\u003cpre\u003e\u003cspan class=\"pl-s\"\u003e\"\"\"Usage: my_program FILE\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e my_program COUNT FILE\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e\"\"\"\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eEach pattern can consist of the following elements:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003cstrong\u003e\u0026lt;arguments\u0026gt;\u003c/strong\u003e, \u003cstrong\u003eARGUMENTS\u003c/strong\u003e. Arguments are specified as either\nupper-case words, e.g. \u003ccode\u003emy_program CONTENT-PATH\u003c/code\u003e or words\nsurrounded by angular brackets: \u003ccode\u003emy_program \u0026lt;content-path\u0026gt;\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003e--options\u003c/strong\u003e. Options are words started with dash (\u003ccode\u003e-\u003c/code\u003e), e.g.\n\u003ccode\u003e--output\u003c/code\u003e, \u003ccode\u003e-o\u003c/code\u003e. You can \"stack\" several of one-letter\noptions, e.g. \u003ccode\u003e-oiv\u003c/code\u003e which will be the same as \u003ccode\u003e-o -i -v\u003c/code\u003e. The\noptions can have arguments, e.g. \u003ccode\u003e--input=FILE\u003c/code\u003e or \u003ccode\u003e-i FILE\u003c/code\u003e or\neven \u003ccode\u003e-iFILE\u003c/code\u003e. However it is important that you specify option\ndescriptions if you want your option to have an argument, a default\nvalue, or specify synonymous short/long versions of the option (see\nnext section on option descriptions).\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003ecommands\u003c/strong\u003e are words that do \u003cem\u003enot\u003c/em\u003e follow the described above\nconventions of \u003ccode\u003e--options\u003c/code\u003e or \u003ccode\u003e\u0026lt;arguments\u0026gt;\u003c/code\u003e or \u003ccode\u003eARGUMENTS\u003c/code\u003e,\nplus two special commands: dash \"\u003ccode\u003e-\u003c/code\u003e\" and double dash \"\u003ccode\u003e--\u003c/code\u003e\"\n(see below).\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eUse the following constructs to specify patterns:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003cstrong\u003e[ ]\u003c/strong\u003e (brackets) \u003cstrong\u003eoptional\u003c/strong\u003e elements. e.g.: \u003ccode\u003emy_program\n[-hvqo FILE]\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003e( )\u003c/strong\u003e (parens) \u003cstrong\u003erequired\u003c/strong\u003e elements. All elements that are \u003cem\u003enot\u003c/em\u003e\nput in \u003cstrong\u003e[ ]\u003c/strong\u003e are also required, e.g.: \u003ccode\u003emy_program\n--path=\u0026lt;path\u0026gt; \u0026lt;file\u0026gt;...\u003c/code\u003e is the same as \u003ccode\u003emy_program\n(--path=\u0026lt;path\u0026gt; \u0026lt;file\u0026gt;...)\u003c/code\u003e. (Note, \"required options\" might be not\na good idea for your users).\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003e|\u003c/strong\u003e (pipe) \u003cstrong\u003emutually exclusive\u003c/strong\u003e elements. Group them using \u003cstrong\u003e(\n)\u003c/strong\u003e if one of the mutually exclusive elements is required:\n\u003ccode\u003emy_program (--clockwise | --counter-clockwise) TIME\u003c/code\u003e. Group\nthem using \u003cstrong\u003e[ ]\u003c/strong\u003e if none of the mutually-exclusive elements are\nrequired: \u003ccode\u003emy_program [--left | --right]\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003e...\u003c/strong\u003e (ellipsis) \u003cstrong\u003eone or more\u003c/strong\u003e elements. To specify that\narbitrary number of repeating elements could be accepted, use\nellipsis (\u003ccode\u003e...\u003c/code\u003e), e.g. \u003ccode\u003emy_program FILE ...\u003c/code\u003e means one or\nmore \u003ccode\u003eFILE\u003c/code\u003e-s are accepted. If you want to accept zero or more\nelements, use brackets, e.g.: \u003ccode\u003emy_program [FILE ...]\u003c/code\u003e. Ellipsis\nworks as a unary operator on the expression to the left.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003e[options]\u003c/strong\u003e (case sensitive) shortcut for any options. You can\nuse it if you want to specify that the usage pattern could be\nprovided with any options defined below in the option-descriptions\nand do not want to enumerate them all in usage-pattern.\u003c/li\u003e\n\u003cli\u003e\"\u003ccode\u003e[--]\u003c/code\u003e\". Double dash \"\u003ccode\u003e--\u003c/code\u003e\" is used by convention to separate\npositional arguments that can be mistaken for options. In order to\nsupport this convention add \"\u003ccode\u003e[--]\u003c/code\u003e\" to your usage patterns.\u003c/li\u003e\n\u003cli\u003e\"\u003ccode\u003e[-]\u003c/code\u003e\". Single dash \"\u003ccode\u003e-\u003c/code\u003e\" is used by convention to signify that\n\u003ccode\u003estdin\u003c/code\u003e is used instead of a file. To support this add \"\u003ccode\u003e[-]\u003c/code\u003e\"\nto your usage patterns. \"\u003ccode\u003e-\u003c/code\u003e\" acts as a normal command.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eIf your pattern allows to match argument-less option (a flag) several\ntimes:\u003c/p\u003e\n\u003cpre\u003eUsage: my_program [-v | -vv | -vvv]\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003ethen number of occurrences of the option will be counted. I.e.\n\u003ccode\u003eargs['-v']\u003c/code\u003e will be \u003ccode\u003e2\u003c/code\u003e if program was invoked as \u003ccode\u003emy_program\n-vv\u003c/code\u003e. Same works for commands.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIf your usage patterns allows to match same-named option with argument\nor positional argument several times, the matched arguments will be\ncollected into a list:\u003c/p\u003e\n\u003cpre\u003eUsage: my_program \u0026lt;file\u0026gt; \u0026lt;file\u0026gt; --path=\u0026lt;path\u0026gt;...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eI.e. invoked with \u003ccode\u003emy_program file1 file2 --path=./here\n--path=./there\u003c/code\u003e the returned dict will contain \u003ccode\u003eargs['\u0026lt;file\u0026gt;'] ==\n['file1', 'file2']\u003c/code\u003e and \u003ccode\u003eargs['--path'] == ['./here', './there']\u003c/code\u003e.\u003c/p\u003e\n\u003ca name=\"user-content-option-descriptions-format\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eOption descriptions format\u003c/h2\u003e\u003ca id=\"user-content-option-descriptions-format\" class=\"anchor\" aria-label=\"Permalink: Option descriptions format\" href=\"#option-descriptions-format\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eOption descriptions\u003c/strong\u003e consist of a list of options that you put\nbelow your usage patterns.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIt is necessary to list option descriptions in order to specify:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003esynonymous short and long options,\u003c/li\u003e\n\u003cli\u003eif an option has an argument,\u003c/li\u003e\n\u003cli\u003eif option's argument has a default value.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eThe rules are as follows:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eEvery line in \u003ccode\u003edoc\u003c/code\u003e that starts with \u003ccode\u003e-\u003c/code\u003e or \u003ccode\u003e--\u003c/code\u003e (not counting\nspaces) is treated as an option description, e.g.:\u003c/p\u003e\n\u003cpre\u003eOptions:\n --verbose # GOOD\n -o FILE # GOOD\nOther: --bad # BAD, line does not start with dash \"-\"\n\u003c/pre\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eTo specify that option has an argument, put a word describing that\nargument after space (or equals \"\u003ccode\u003e=\u003c/code\u003e\" sign) as shown below. Follow\neither \u0026lt;angular-brackets\u0026gt; or UPPER-CASE convention for options'\narguments. You can use comma if you want to separate options. In\nthe example below, both lines are valid, however you are recommended\nto stick to a single style.:\u003c/p\u003e\n\u003cpre\u003e-o FILE --output=FILE # without comma, with \"=\" sign\n-i \u0026lt;file\u0026gt;, --input \u0026lt;file\u0026gt; # with comma, without \"=\" sing\n\u003c/pre\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eUse two spaces to separate options with their informal description:\u003c/p\u003e\n\u003cpre\u003e--verbose More text. # BAD, will be treated as if verbose option had\n # an argument \"More\", so use 2 spaces instead\n-q Quit. # GOOD\n-o FILE Output file. # GOOD\n--stdout Use stdout. # GOOD, 2 spaces\n\u003c/pre\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eIf you want to set a default value for an option with an argument,\nput it into the option-description, in form \u003ccode\u003e[default:\n\u0026lt;my-default-value\u0026gt;]\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003e--coefficient=K The K coefficient [default: 2.95]\n--output=FILE Output file [default: test.txt]\n--directory=DIR Some directory [default: ./]\n\u003c/pre\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eIf the option is not repeatable, the value inside \u003ccode\u003e[default: ...]\u003c/code\u003e\nwill be interpreted as string. If it \u003cem\u003eis\u003c/em\u003e repeatable, it will be\nsplited into a list on whitespace:\u003c/p\u003e\n\u003cpre\u003eUsage: my_program [--repeatable=\u0026lt;arg\u0026gt; --repeatable=\u0026lt;arg\u0026gt;]\n [--another-repeatable=\u0026lt;arg\u0026gt;]...\n [--not-repeatable=\u0026lt;arg\u0026gt;]\n\n# will be ['./here', './there']\n--repeatable=\u0026lt;arg\u0026gt; [default: ./here ./there]\n\n# will be ['./here']\n--another-repeatable=\u0026lt;arg\u0026gt; [default: ./here]\n\n# will be './here ./there', because it is not repeatable\n--not-repeatable=\u0026lt;arg\u0026gt; [default: ./here ./there]\n\u003c/pre\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-examples\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eExamples\u003c/h2\u003e\u003ca id=\"user-content-examples\" class=\"anchor\" aria-label=\"Permalink: Examples\" href=\"#examples\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eWe have an extensive list of \u003ca href=\"https://github.com/docopt/docopt/tree/master/examples\"\u003eexamples\u003c/a\u003e which cover\nevery aspect of functionality of \u003cstrong\u003edocopt\u003c/strong\u003e. Try them out, read the\nsource if in doubt.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThere are also very intersting applications and ideas at that page.\nCheck out the sister project for more information!\u003c/p\u003e\n\u003ca name=\"user-content-subparsers-multi-level-help-and-huge-applications-like-git\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eSubparsers, multi-level help and \u003cem\u003ehuge\u003c/em\u003e applications (like git)\u003c/h2\u003e\u003ca id=\"user-content-subparsers-multi-level-help-and-huge-applications-like-git\" class=\"anchor\" aria-label=\"Permalink: Subparsers, multi-level help and huge applications (like git)\" href=\"#subparsers-multi-level-help-and-huge-applications-like-git\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIf you want to split your usage-pattern into several, implement\nmulti-level help (with separate help-screen for each subcommand),\nwant to interface with existing scripts that don't use \u003cstrong\u003edocopt\u003c/strong\u003e, or\nyou're building the next \"git\", you will need the new \u003ccode\u003eoptions_first\u003c/code\u003e\nparameter (described in API section above). To get you started quickly\nwe implemented a subset of git command-line interface as an example:\n\u003ca href=\"https://github.com/docopt/docopt/tree/master/examples/git\"\u003eexamples/git\u003c/a\u003e\u003c/p\u003e\n\u003ca name=\"user-content-compiling-the-example-running-the-tests\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eCompiling the example / Running the tests\u003c/h2\u003e\u003ca id=\"user-content-compiling-the-example--running-the-tests\" class=\"anchor\" aria-label=\"Permalink: Compiling the example / Running the tests\" href=\"#compiling-the-example--running-the-tests\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe original Python module includes some language-agnostic unit tests,\nand these can be run with this port as well.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe tests are a Python driver that uses the testcases.docopt file to then invoke\na C++ test case runner (run_testcase.cpp):\u003c/p\u003e\n\u003cpre\u003e$ clang++ --std=c++11 --stdlib=libc++ docopt.cpp run_testcase.cpp -o run_testcase\n$ python run_tests.py\nPASS (175)\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eYou can also compile the example shown at the start (included as example.cpp):\u003c/p\u003e\n\u003cpre\u003e$ clang++ --std=c++11 --stdlib=libc++ -I . docopt.cpp examples/naval_fate.cpp -o naval_fate\n$ ./naval_fate --help\n [ ... ]\n$ ./naval_fate ship Guardian move 100 150 --speed=15\n--drifting: false\n--help: false\n--moored: false\n--speed: \"15\"\n--version: false\n\u0026lt;name\u0026gt;: [\"Guardian\"]\n\u0026lt;x\u0026gt;: \"100\"\n\u0026lt;y\u0026gt;: \"150\"\nmine: false\nmove: true\nnew: false\nremove: false\nset: false\nship: true\nshoot: false\n\u003c/pre\u003e\n\u003ca name=\"user-content-development\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eDevelopment\u003c/h2\u003e\u003ca id=\"user-content-development\" class=\"anchor\" aria-label=\"Permalink: Development\" href=\"#development\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eComments and suggestions are \u003cem\u003every\u003c/em\u003e welcome! If you find issues, please\nfile them and help improve our code!\u003c/p\u003e\n\u003cp dir=\"auto\"\u003ePlease note, however, that we have tried to stay true to the original\nPython code. If you have any major patches, structural changes, or new features,\nwe might want to first negotiate these changes into the Python code first.\nHowever, bring it up! Let's hear it!\u003c/p\u003e\n\u003ca name=\"user-content-changelog\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eChangelog\u003c/h2\u003e\u003ca id=\"user-content-changelog\" class=\"anchor\" aria-label=\"Permalink: Changelog\" href=\"#changelog\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003edocopt\u003c/strong\u003e follows \u003ca href=\"http://semver.org\" rel=\"nofollow\"\u003esemantic versioning\u003c/a\u003e. The\nfirst release with stable API will be 1.0.0 (soon).\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e0.6.1 The initial C++ port of docopt.py\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003c/article\u003e","renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":null},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/OSVR/docopt.cpp/branches":{"post":"urYBmUm-tc0GI-dHGwX1Y251alDoZU65fAm3o_zSZJJUoioi0T-TAcV9DjzphRXCWvNaVphbwWoh6MBAL0XO8A"},"/repos/preferences":{"post":"CrOjzzK20lwU-i2cALurq8e5tHk4NpQ9LrV8hf9yRUM7vQYVXS2Fx35emDSWQKSqaFijLBB7y0HDuzrGA2ofUQ"}}},"title":"docopt.cpp/README.rst at master · OSVR/docopt.cpp","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-b84e9496fc59.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}