MCPcopy Create free account
hub / github.com/docopt/docopt.cpp / docopt

Method docopt

docopt.cpp:661–687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

659}
660
661DOCOPT_INLINE
662docopt::Options
663docopt::docopt(std::string const& doc,
664 std::vector<std::string> const& argv,
665 bool help,
666 std::string const& version,
667 bool options_first) noexcept
668{
669 try {
670 return docopt_parse(doc, argv, help, !version.empty(), options_first);
671 } catch (DocoptExitHelp const&) {
672 std::cout << doc << std::endl;
673 std::exit(0);
674 } catch (DocoptExitVersion const&) {
675 std::cout << version << std::endl;
676 std::exit(0);
677 } catch (DocoptLanguageError const& error) {
678 std::cerr << "Docopt usage string could not be parsed" << std::endl;
679 std::cerr << error.what() << std::endl;
680 std::exit(-1);
681 } catch (DocoptArgumentError const& error) {
682 std::cerr << error.what();
683 std::cout << std::endl;
684 std::cout << doc << std::endl;
685 std::exit(-1);
686 } /* Any other exception is unexpected: let std::terminate grab it */
687}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected