PLearn 0.1
|
#include <HelpCommand.h>
Public Member Functions | |
HelpCommand () | |
virtual void | run (const vector< string > &args) |
The actual implementation of the 'HelpCommand' command. | |
Protected Member Functions | |
void | helpOverview () |
void | helpAboutPLearnScript (const string &fname) |
void | helpAboutPyPLearnScript (const string &fname) |
void | helpScripts () |
void | helpCommands () |
void | helpDatasets () |
void | helpObject (const string &objectname="") |
Static Protected Attributes | |
static PLearnCommandRegistry | reg_ |
This allows to register the 'HelpCommand' command in the command registry. |
Definition at line 49 of file HelpCommand.h.
PLearn::HelpCommand::HelpCommand | ( | ) | [inline] |
Definition at line 62 of file HelpCommand.h.
: PLearnCommand("help", "plearn command-line help", "help <topic>\n" "Run the help command with no argument to get an overview of the system.\n" ) {}
void PLearn::HelpCommand::helpAboutPLearnScript | ( | const string & | fname | ) | [protected] |
Definition at line 143 of file HelpCommand.cc.
References PLearn::endl(), PLearn::isfile(), PLERROR, and PLearn::pout.
{ if(!isfile(fname)) PLERROR("Could not open script file %s", fname.c_str()); pout << "Help about a .plearn script file not yet implemented \n" << endl; }
void PLearn::HelpCommand::helpAboutPyPLearnScript | ( | const string & | fname | ) | [protected] |
Definition at line 152 of file HelpCommand.cc.
References PLearn::PPath::absolute(), PLearn::endl(), PLearn::execute(), PLearn::isfile(), PLERROR, and PLearn::pout.
{ if(!isfile(fname)) PLERROR("Could not open script file %s", fname.c_str()); pout << "#######################################################" << endl; pout << "### Help on pyplearn script " << fname << endl; pout << "#######################################################" << endl; string command; #ifdef WIN32 command = "python.exe "+PPath("PLEARNDIR:scripts/pyplearn_driver.py").absolute(); #else command = "pyplearn_driver.py"; #endif vector<string> helptext = execute(command+" "+fname+" --help"); vector<string>::const_iterator it = helptext.begin(); while(it!=helptext.end()) pout << *it++ << endl; }
void PLearn::HelpCommand::helpCommands | ( | ) | [protected] |
Definition at line 125 of file HelpCommand.cc.
References PLearn::endl(), PLearn::HelpSystem::helpCommands(), PLearn::pout, and PLearn::prgname().
{ pout << "To run a command, type:" << " % " + prgname() + " command_name command_arguments \n" << endl; pout << "Available commands are: " << endl; pout << HelpSystem::helpCommands() << endl; pout << "For more details on a specific command, type: \n" << " % " << prgname() << " help <command_name> \n" << endl; }
void PLearn::HelpCommand::helpDatasets | ( | ) | [protected] |
Definition at line 138 of file HelpCommand.cc.
References PLearn::endl(), PLearn::getDataSetHelp(), and PLearn::pout.
{ pout << getDataSetHelp() << endl; }
void PLearn::HelpCommand::helpObject | ( | const string & | objectname = "" | ) | [protected] |
void PLearn::HelpCommand::helpOverview | ( | ) | [protected] |
Definition at line 56 of file HelpCommand.cc.
References PLearn::endl(), PLearn::pout, and PLearn::prgname().
{ pout << "To run a .plearn script type: " + prgname() + " scriptfile.plearn \n" "To run a command type: " + prgname() + " command [ command arguments ] \n\n" "To get help on the script file format: " + prgname() + " help scripts \n" "To get a short description of available commands: " + prgname() + " help commands \n" "To get detailed help on a specific command: " + prgname() + " help <command_name> \n" "To get help on a specific PLearn object: " + prgname() + " help <object_type_name> \n" "To get help on datasets: " + prgname() + " help datasets \n\n" "" "Global parameter:\n" " --no-progress: do not print progress bar\n" " --no-version: do not print the version \n" " --windows_endl: use Windows end of line\n" " --profile: print some profiling information\n" " Must have been compiled with '-logging=dbg-profile'\n" " --profile-wall: same as above except we only print the wall time\n" " --verbosity LEVEL: The level of log to print.\n" " Must have been compiled with the same level of more\n" " Available level:\n" " VLEVEL_MAND // Mandatory\n" " VLEVEL_IMP // Important\n" " VLEVEL_NORMAL // Normal (Default)\n" " VLEVEL_DBG // Debug Info\n" " VLEVEL_EXTREME // Extreme Verbosity\n" " --enable-logging module1,module2,module3,...:\n" " Option to enable logging for the specified modules,\n" " specified a comma-separated list of modules (without spaces).\n" " Special keywords __ALL__ and __NONE__ can be specified to log\n" " for all modules or no modules respectively.\n" " --servers\n" " --global-calendars" << endl; }
void PLearn::HelpCommand::helpScripts | ( | ) | [protected] |
Definition at line 92 of file HelpCommand.cc.
References PLearn::endl(), PLearn::pout, and PLearn::prgname().
{ pout << "You can run plearn with the name of a plearn script file as argument\n" "A plearn script file should have a name ending in .plearn\n\n" "A plearn script must contain at least one runnable PLearn object\n" "A typical runnable PLearn object is 'PTester' \n" "\n" "You can type '" + prgname() + " help xxx' to get a description and the list of build options\n" "for any PLearn object xxx linked with the program\n" "\n" "A plearn script can use macro variable definitions and expansion. Macro commands start by a $\n" "ex: $DEFINE{toto}{[1,2,3,4]} ${toto} $INCLUDE{otherfile.pscript} \n" "Macro variable definitions can also be provided on the command line in the form \n" "varname=varvalue with each such pair separated by a blank, thus\n" "allowing for scripts with arguments\n" "In addition, the following variables are automatically defined from the script's filepath: \n" "FILEPATH DIRPATH FILENAME FILEBASE FILEEXT \n" "Ex: if the absolute path to the script file is /home/me/foo.plearn \n" " Then we'll get: \n" "FILEPATH = /home/me/foo.plearn \n" "DIRPATH = /home/me \n" "FILENAME = foo.plearn \n" "FILEBASE = foo \n" "FILEEXT = .plearn \n" "\n" "The additional variables are also available:\n" "DATE = Date in YYYYMMDD format\n" "TIME = Time in HHMMSS format\n" "DATETIME = Date and time in YYYYMMDD:HHMMSS format\n" << endl; }
void PLearn::HelpCommand::run | ( | const vector< string > & | args | ) | [virtual] |
The actual implementation of the 'HelpCommand' command.
Implements PLearn::PLearnCommand.
Definition at line 174 of file HelpCommand.cc.
References PLearn::extract_extension(), PLearn::flush(), PLearn::HelpSystem::helpOnClass(), PLearn::HelpSystem::helpOnCommand(), PLearn::PLearnCommandRegistry::is_registered(), PLearn::OptionBase::optionLevelFromString(), PLearn::pout, and PLearn::OptionBase::setCurrentOptionLevel().
{ if(args.size()==0) helpOverview();//TODO: move to HelpSystem else { string about = args[0]; string aboutext = extract_extension(about); if(args.size() > 1)//is option level present? OptionBase::setCurrentOptionLevel( OptionBase::optionLevelFromString(args[1])); // Note: some of these functions could be moved to HelpSystem if(aboutext==".plearn") // help is asked about a plearn script helpAboutPLearnScript(about); else if(aboutext==".pyplearn") // help is asked about a pyplearn script helpAboutPyPLearnScript(about); else if(about=="scripts") helpScripts(); else if(about=="commands") helpCommands(); else if(about=="datasets") helpDatasets();//TODO: move to HelpSystem else if(PLearnCommandRegistry::is_registered(about)) pout << HelpSystem::helpOnCommand(about) << flush; else pout << HelpSystem::helpOnClass(about) << flush; } }
PLearnCommandRegistry PLearn::HelpCommand::reg_ [static, protected] |
This allows to register the 'HelpCommand' command in the command registry.
Definition at line 74 of file HelpCommand.h.