// -*- C++ -*- // // This file was generated by CLI, a command line interface // compiler for C++. // // Begin prologue. // #include // // End prologue. #include #include #include #include #include #include #include #include #include namespace bdep { namespace cli { template struct parser { static void parse (X& x, bool& xs, scanner& s) { using namespace std; const char* o (s.next ()); if (s.more ()) { string v (s.next ()); istringstream is (v); if (!(is >> x && is.peek () == istringstream::traits_type::eof ())) throw invalid_value (o, v); } else throw missing_value (o); xs = true; } static void merge (X& b, const X& a) { b = a; } }; template <> struct parser { static void parse (bool& x, bool& xs, scanner& s) { const char* o (s.next ()); if (s.more ()) { const char* v (s.next ()); if (std::strcmp (v, "1") == 0 || std::strcmp (v, "true") == 0 || std::strcmp (v, "TRUE") == 0 || std::strcmp (v, "True") == 0) x = true; else if (std::strcmp (v, "0") == 0 || std::strcmp (v, "false") == 0 || std::strcmp (v, "FALSE") == 0 || std::strcmp (v, "False") == 0) x = false; else throw invalid_value (o, v); } else throw missing_value (o); xs = true; } static void merge (bool& b, const bool&) { b = true; } }; template <> struct parser { static void parse (std::string& x, bool& xs, scanner& s) { const char* o (s.next ()); if (s.more ()) x = s.next (); else throw missing_value (o); xs = true; } static void merge (std::string& b, const std::string& a) { b = a; } }; template struct parser > { static void parse (std::pair& x, bool& xs, scanner& s) { x.second = s.position (); parser::parse (x.first, xs, s); } static void merge (std::pair& b, const std::pair& a) { b = a; } }; template struct parser > { static void parse (std::vector& c, bool& xs, scanner& s) { X x; bool dummy; parser::parse (x, dummy, s); c.push_back (x); xs = true; } static void merge (std::vector& b, const std::vector& a) { b.insert (b.end (), a.begin (), a.end ()); } }; template struct parser > { static void parse (std::set& c, bool& xs, scanner& s) { X x; bool dummy; parser::parse (x, dummy, s); c.insert (x); xs = true; } static void merge (std::set& b, const std::set& a) { b.insert (a.begin (), a.end ()); } }; template struct parser > { static void parse (std::map& m, bool& xs, scanner& s) { const char* o (s.next ()); if (s.more ()) { std::size_t pos (s.position ()); std::string ov (s.next ()); std::string::size_type p = ov.find ('='); K k = K (); V v = V (); std::string kstr (ov, 0, p); std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); int ac (2); char* av[] = { const_cast (o), 0 }; bool dummy; if (!kstr.empty ()) { av[1] = const_cast (kstr.c_str ()); argv_scanner s (0, ac, av, false, pos); parser::parse (k, dummy, s); } if (!vstr.empty ()) { av[1] = const_cast (vstr.c_str ()); argv_scanner s (0, ac, av, false, pos); parser::parse (v, dummy, s); } m[k] = v; } else throw missing_value (o); xs = true; } static void merge (std::map& b, const std::map& a) { for (typename std::map::const_iterator i (a.begin ()); i != a.end (); ++i) b[i->first] = i->second; } }; template struct parser > { static void parse (std::multimap& m, bool& xs, scanner& s) { const char* o (s.next ()); if (s.more ()) { std::size_t pos (s.position ()); std::string ov (s.next ()); std::string::size_type p = ov.find ('='); K k = K (); V v = V (); std::string kstr (ov, 0, p); std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); int ac (2); char* av[] = { const_cast (o), 0 }; bool dummy; if (!kstr.empty ()) { av[1] = const_cast (kstr.c_str ()); argv_scanner s (0, ac, av, false, pos); parser::parse (k, dummy, s); } if (!vstr.empty ()) { av[1] = const_cast (vstr.c_str ()); argv_scanner s (0, ac, av, false, pos); parser::parse (v, dummy, s); } m.insert (typename std::multimap::value_type (k, v)); } else throw missing_value (o); xs = true; } static void merge (std::multimap& b, const std::multimap& a) { for (typename std::multimap::const_iterator i (a.begin ()); i != a.end (); ++i) b.insert (typename std::multimap::value_type (i->first, i->second)); } }; template void thunk (X& x, scanner& s) { parser::parse (x.*M, s); } template void thunk (X& x, scanner& s) { s.next (); x.*M = true; } template void thunk (X& x, scanner& s) { parser::parse (x.*M, x.*S, s); } } } #include namespace bdep { // cmd_status_options // cmd_status_options:: cmd_status_options () : immediate_ (), recursive_ (), old_available_ (), fetch_ (), fetch_full_ () { } bool cmd_status_options:: parse (int& argc, char** argv, bool erase, ::bdep::cli::unknown_mode opt, ::bdep::cli::unknown_mode arg) { ::bdep::cli::argv_scanner s (argc, argv, erase); bool r = _parse (s, opt, arg); return r; } bool cmd_status_options:: parse (int start, int& argc, char** argv, bool erase, ::bdep::cli::unknown_mode opt, ::bdep::cli::unknown_mode arg) { ::bdep::cli::argv_scanner s (start, argc, argv, erase); bool r = _parse (s, opt, arg); return r; } bool cmd_status_options:: parse (int& argc, char** argv, int& end, bool erase, ::bdep::cli::unknown_mode opt, ::bdep::cli::unknown_mode arg) { ::bdep::cli::argv_scanner s (argc, argv, erase); bool r = _parse (s, opt, arg); end = s.end (); return r; } bool cmd_status_options:: parse (int start, int& argc, char** argv, int& end, bool erase, ::bdep::cli::unknown_mode opt, ::bdep::cli::unknown_mode arg) { ::bdep::cli::argv_scanner s (start, argc, argv, erase); bool r = _parse (s, opt, arg); end = s.end (); return r; } bool cmd_status_options:: parse (::bdep::cli::scanner& s, ::bdep::cli::unknown_mode opt, ::bdep::cli::unknown_mode arg) { bool r = _parse (s, opt, arg); return r; } void cmd_status_options:: merge (const cmd_status_options& a) { CLI_POTENTIALLY_UNUSED (a); // project_options base // ::bdep::project_options::merge (a); if (a.immediate_) { ::bdep::cli::parser< bool>::merge ( this->immediate_, a.immediate_); } if (a.recursive_) { ::bdep::cli::parser< bool>::merge ( this->recursive_, a.recursive_); } if (a.old_available_) { ::bdep::cli::parser< bool>::merge ( this->old_available_, a.old_available_); } if (a.fetch_) { ::bdep::cli::parser< bool>::merge ( this->fetch_, a.fetch_); } if (a.fetch_full_) { ::bdep::cli::parser< bool>::merge ( this->fetch_full_, a.fetch_full_); } } ::bdep::cli::usage_para cmd_status_options:: print_usage (::std::ostream& os, ::bdep::cli::usage_para p) { CLI_POTENTIALLY_UNUSED (os); if (p != ::bdep::cli::usage_para::none) os << ::std::endl; os << "\033[1mSTATUS OPTIONS\033[0m" << ::std::endl; os << std::endl << "\033[1m--immediate\033[0m|\033[1m-i\033[0m Also print the status of immediate dependencies." << ::std::endl; os << std::endl << "\033[1m--recursive\033[0m|\033[1m-r\033[0m Also print the status of all dependencies," << ::std::endl << " recursively." << ::std::endl; os << std::endl << "\033[1m--old-available\033[0m|\033[1m-o\033[0m Print old available versions." << ::std::endl; os << std::endl << "\033[1m--fetch\033[0m|\033[1m-f\033[0m Perform the \033[1mfetch\033[0m command prior to printing the" << ::std::endl << " status." << ::std::endl; os << std::endl << "\033[1m--fetch-full\033[0m|\033[1m-F\033[0m Perform the \033[1mfetch --full\033[0m command prior to printing" << ::std::endl << " the status." << ::std::endl; p = ::bdep::cli::usage_para::option; // project_options base // p = ::bdep::project_options::print_usage (os, p); return p; } struct _cli_cmd_status_options_desc_type: ::bdep::cli::options { _cli_cmd_status_options_desc_type () { ::bdep::cmd_status_options::fill (*this); } }; void cmd_status_options:: fill (::bdep::cli::options& os) { // project_options base // ::bdep::project_options::fill (os); // --immediate // { ::bdep::cli::option_names a; a.push_back ("-i"); std::string dv; ::bdep::cli::option o ("--immediate", a, true, dv); os.push_back (o); } // --recursive // { ::bdep::cli::option_names a; a.push_back ("-r"); std::string dv; ::bdep::cli::option o ("--recursive", a, true, dv); os.push_back (o); } // --old-available // { ::bdep::cli::option_names a; a.push_back ("-o"); std::string dv; ::bdep::cli::option o ("--old-available", a, true, dv); os.push_back (o); } // --fetch // { ::bdep::cli::option_names a; a.push_back ("-f"); std::string dv; ::bdep::cli::option o ("--fetch", a, true, dv); os.push_back (o); } // --fetch-full // { ::bdep::cli::option_names a; a.push_back ("-F"); std::string dv; ::bdep::cli::option o ("--fetch-full", a, true, dv); os.push_back (o); } } const ::bdep::cli::options& cmd_status_options:: description () { static _cli_cmd_status_options_desc_type _cli_cmd_status_options_desc_; return _cli_cmd_status_options_desc_; } typedef std::map _cli_cmd_status_options_map; static _cli_cmd_status_options_map _cli_cmd_status_options_map_; struct _cli_cmd_status_options_map_init { _cli_cmd_status_options_map_init () { _cli_cmd_status_options_map_["--immediate"] = &::bdep::cli::thunk< cmd_status_options, &cmd_status_options::immediate_ >; _cli_cmd_status_options_map_["-i"] = &::bdep::cli::thunk< cmd_status_options, &cmd_status_options::immediate_ >; _cli_cmd_status_options_map_["--recursive"] = &::bdep::cli::thunk< cmd_status_options, &cmd_status_options::recursive_ >; _cli_cmd_status_options_map_["-r"] = &::bdep::cli::thunk< cmd_status_options, &cmd_status_options::recursive_ >; _cli_cmd_status_options_map_["--old-available"] = &::bdep::cli::thunk< cmd_status_options, &cmd_status_options::old_available_ >; _cli_cmd_status_options_map_["-o"] = &::bdep::cli::thunk< cmd_status_options, &cmd_status_options::old_available_ >; _cli_cmd_status_options_map_["--fetch"] = &::bdep::cli::thunk< cmd_status_options, &cmd_status_options::fetch_ >; _cli_cmd_status_options_map_["-f"] = &::bdep::cli::thunk< cmd_status_options, &cmd_status_options::fetch_ >; _cli_cmd_status_options_map_["--fetch-full"] = &::bdep::cli::thunk< cmd_status_options, &cmd_status_options::fetch_full_ >; _cli_cmd_status_options_map_["-F"] = &::bdep::cli::thunk< cmd_status_options, &cmd_status_options::fetch_full_ >; } }; static _cli_cmd_status_options_map_init _cli_cmd_status_options_map_init_; bool cmd_status_options:: _parse (const char* o, ::bdep::cli::scanner& s) { _cli_cmd_status_options_map::const_iterator i (_cli_cmd_status_options_map_.find (o)); if (i != _cli_cmd_status_options_map_.end ()) { (*(i->second)) (*this, s); return true; } // project_options base // if (::bdep::project_options::_parse (o, s)) return true; return false; } bool cmd_status_options:: _parse (::bdep::cli::scanner& s, ::bdep::cli::unknown_mode opt_mode, ::bdep::cli::unknown_mode arg_mode) { // Can't skip combined flags (--no-combined-flags). // assert (opt_mode != ::bdep::cli::unknown_mode::skip); bool r = false; bool opt = true; while (s.more ()) { const char* o = s.peek (); if (std::strcmp (o, "--") == 0) { opt = false; } if (opt) { if (_parse (o, s)) { r = true; continue; } if (std::strncmp (o, "-", 1) == 0 && o[1] != '\0') { // Handle combined option values. // std::string co; if (const char* v = std::strchr (o, '=')) { co.assign (o, 0, v - o); ++v; int ac (2); char* av[] = { const_cast (co.c_str ()), const_cast (v) }; ::bdep::cli::argv_scanner ns (0, ac, av); if (_parse (co.c_str (), ns)) { // Parsed the option but not its value? // if (ns.end () != 2) throw ::bdep::cli::invalid_value (co, v); s.next (); r = true; continue; } else { // Set the unknown option and fall through. // o = co.c_str (); } } // Handle combined flags. // char cf[3]; { const char* p = o + 1; for (; *p != '\0'; ++p) { if (!((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9'))) break; } if (*p == '\0') { for (p = o + 1; *p != '\0'; ++p) { std::strcpy (cf, "-"); cf[1] = *p; cf[2] = '\0'; int ac (1); char* av[] = { cf }; ::bdep::cli::argv_scanner ns (0, ac, av); if (!_parse (cf, ns)) break; } if (*p == '\0') { // All handled. // s.next (); r = true; continue; } else { // Set the unknown option and fall through. // o = cf; } } } switch (opt_mode) { case ::bdep::cli::unknown_mode::skip: { s.skip (); r = true; continue; } case ::bdep::cli::unknown_mode::stop: { break; } case ::bdep::cli::unknown_mode::fail: { throw ::bdep::cli::unknown_option (o); } } break; } } switch (arg_mode) { case ::bdep::cli::unknown_mode::skip: { s.skip (); r = true; continue; } case ::bdep::cli::unknown_mode::stop: { break; } case ::bdep::cli::unknown_mode::fail: { throw ::bdep::cli::unknown_argument (o); } } break; } return r; } } namespace bdep { ::bdep::cli::usage_para print_bdep_status_usage (::std::ostream& os, ::bdep::cli::usage_para p) { CLI_POTENTIALLY_UNUSED (os); if (p != ::bdep::cli::usage_para::none) os << ::std::endl; os << "\033[1mSYNOPSIS\033[0m" << ::std::endl << ::std::endl << "\033[1mbdep status\033[0m [\033[4moptions\033[0m] [\033[4mpkg-spec\033[0m] [\033[4mcfg-spec\033[0m] [\033[4mdep-spec\033[0m...]\033[0m" << ::std::endl << ::std::endl << "\033[4mdep-spec\033[0m = \033[4mpkg\033[0m[\033[1m/\033[0m\033[4mver\033[0m]" << ::std::endl << "\033[4mcfg-spec\033[0m = (\033[1m@\033[0m\033[4mcfg-name\033[0m | \033[1m--config\033[0m|\033[1m-c\033[0m \033[4mcfg-dir\033[0m)... | \033[1m--all\033[0m|\033[1m-a\033[0m" << ::std::endl << "\033[4mpkg-spec\033[0m = (\033[1m--directory\033[0m|\033[1m-d\033[0m \033[4mpkg-dir\033[0m)... | \033[4mprj-spec\033[0m" << ::std::endl << "\033[4mprj-spec\033[0m = \033[1m--directory\033[0m|\033[1m-d\033[0m \033[4mprj-dir\033[0m\033[0m" << ::std::endl << ::std::endl << "\033[1mDESCRIPTION\033[0m" << ::std::endl << ::std::endl << "The \033[1mstatus\033[0m command prints the status of project packages and/or their" << ::std::endl << "dependencies in one or more build configurations." << ::std::endl << ::std::endl << "If no project or package directory is specified, then the current working" << ::std::endl << "directory is assumed. If no configuration is specified, then the default" << ::std::endl << "configurations are assumed. See \033[1mbdep-projects-configs(1)\033[0m for details on" << ::std::endl << "specifying projects and configurations." << ::std::endl << ::std::endl << "If no \033[4mdep-spec\033[0m arguments are specified, then \033[1mstatus\033[0m prints the status of the" << ::std::endl << "project's packages. Otherwise, the status of the specified dependency packages" << ::std::endl << "is printed. Additionally, the status of immediate or all dependencies of the" << ::std::endl << "above packages can be printed by specifying the \033[1m--immediate\033[0m|\033[1m-i\033[0m\033[0m or" << ::std::endl << "\033[1m--recursive\033[0m|\033[1m-r\033[0m\033[0m options, respectively." << ::std::endl << ::std::endl << "In the default output format (see the \033[1m--stdout-format\033[0m common option), the" << ::std::endl << "status of each package is printed on a separate line. Note that the status is" << ::std::endl << "written to \033[1mstdout\033[0m, not \033[1mstderr\033[0m. The semantics of \033[4mdep-spec\033[0m and the format of the" << ::std::endl << "status line are described in \033[1mbpkg-pkg-status(1)\033[0m." << ::std::endl << ::std::endl << "If the output format is \033[1mjson\033[0m, then the output is a JSON array of objects which" << ::std::endl << "are the serialized representation of the following C++ \033[1mstruct\033[0m" << ::std::endl << "\033[1mconfiguration_package_status\033[0m:" << ::std::endl << ::std::endl << "struct configuration" << ::std::endl << "{" << ::std::endl << " uint64_t id;" << ::std::endl << " string path;" << ::std::endl << " optional name;" << ::std::endl << "};" << ::std::endl << ::std::endl << "struct configuration_package_status" << ::std::endl << "{" << ::std::endl << " configuration configuration;" << ::std::endl << " vector packages;" << ::std::endl << "};" << ::std::endl << ::std::endl << "For example:" << ::std::endl << ::std::endl << "[" << ::std::endl << " {" << ::std::endl << " \"configuration\": {" << ::std::endl << " \"id\": 1," << ::std::endl << " \"path\": \"/tmp/hello-gcc\"," << ::std::endl << " \"name\": \"gcc\"" << ::std::endl << " }," << ::std::endl << " \"packages\": [" << ::std::endl << " {" << ::std::endl << " \"name\": \"hello\"," << ::std::endl << " \"status\": \"configured\"," << ::std::endl << " \"version\": \"1.0.0\"," << ::std::endl << " \"hold_package\": true," << ::std::endl << " \"available_versions\": [" << ::std::endl << " {" << ::std::endl << " \"version\": \"1.0.1\"" << ::std::endl << " }," << ::std::endl << " {" << ::std::endl << " \"version\": \"2.0.0\"" << ::std::endl << " }" << ::std::endl << " ]," << ::std::endl << " \"dependencies\": [" << ::std::endl << " {" << ::std::endl << " \"name\": \"libhello\"," << ::std::endl << " \"status\": \"configured\"," << ::std::endl << " \"version\": \"1.0.2\"" << ::std::endl << " }" << ::std::endl << " ]" << ::std::endl << " }" << ::std::endl << " ]" << ::std::endl << " }" << ::std::endl << "]" << ::std::endl << ::std::endl << "See the JSON OUTPUT section in \033[1mbdep-common-options(1)\033[0m for details on the" << ::std::endl << "overall properties of this format and the semantics of the \033[1mstruct\033[0m" << ::std::endl << "serialization." << ::std::endl << ::std::endl << "Refer to the \033[1mlist\033[0m subcommand of \033[1mbdep-config(1)\033[0m for details on the \033[1mstruct\033[0m" << ::std::endl << "\033[1mconfiguration\033[0m members. Refer to \033[1mbpkg-pkg-status(1)\033[0m for the definition of" << ::std::endl << "\033[1mstruct\033[0m \033[1mpackage_status\033[0m. Note also that in the \033[1mjson\033[0m output format certain" << ::std::endl << "conditions (no associated configurations, no initialized packages, etc) are not" << ::std::endl << "treated as errors but instead result in valid output. The uninitialized" << ::std::endl << "packages have the special \033[1muninitialized\033[0m \033[1mstatus\033[0m value." << ::std::endl; p = ::bdep::cmd_status_options::print_usage (os, ::bdep::cli::usage_para::text); if (p != ::bdep::cli::usage_para::none) os << ::std::endl; os << "\033[1mDEFAULT OPTIONS FILES\033[0m" << ::std::endl << ::std::endl << "See \033[1mbdep-default-options-files(1)\033[0m for an overview of the default options files." << ::std::endl << "For the \033[1mstatus\033[0m command the search start directory is the project directory. The" << ::std::endl << "following options files are searched for in each directory and, if found," << ::std::endl << "loaded in the order listed:" << ::std::endl << ::std::endl << "bdep.options" << ::std::endl << "bdep-status.options" << ::std::endl << ::std::endl << "The following \033[1mstatus\033[0m command options cannot be specified in the default options" << ::std::endl << "files:" << ::std::endl << ::std::endl << "--directory|-d" << ::std::endl; p = ::bdep::cli::usage_para::text; return p; } } // Begin epilogue. // // // End epilogue.