// file : bpkg/help.cxx -*- C++ -*- // copyright : Copyright (c) 2014-2015 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file #include #include #include #include #include #include using namespace std; namespace bpkg { static void help () { ostream& o (cout); o << "usage: bpkg --help" << endl << " bpkg --version" << endl << " bpkg help [|]" << endl << " bpkg [] [] " << "[]" << endl << endl; o << "The commands are:" << endl << endl; bpkg_commands::print_short_usage (o); o << endl; o << "The help topics are:" << endl << endl; bpkg_topics::print_short_usage (o); o << endl; o << "The common options are summarized below. Note that they can also " "be specified" << endl << "as part of the command-specific options." << endl << endl; common_options::print_short_usage (o); o << endl; o << ""<< endl; } void help (const help_options&, const string& t, void (*usage) (std::ostream&)) { ostream& o (cout); if (usage != nullptr) // Command. { usage (o); o << endl << "The common options are summarized below. For details, see the " << "'options' help" << endl << "topic." << endl << endl; common_options::print_short_usage (o); } else if (t.empty ()) // General help. help (); else if (t == "options") // Help topics. { common_options::print_long_usage (cout); } else fail << "unknown bpkg command/help topic '" << t << "'" << info << "run 'bpkg help' for more information"; } }