/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * * * This file is part of MoleCuilder. * * MoleCuilder is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MoleCuilder is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MoleCuilder. If not, see . */ /* * HelpAction.cpp * * Created on: May 8, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include #include #include "Actions/ActionRegistry.hpp" #include "Actions/ActionTrait.hpp" #include "Actions/OptionRegistry.hpp" #include "Actions/OptionTrait.hpp" #include "CodePatterns/Log.hpp" #include "Actions/CommandAction/HelpAction.hpp" using namespace MoleCuilder; // and construct the stuff #include "HelpAction.def" #include "Action_impl_pre.hpp" /** =========== define the function ====================== */ Action::state_ptr CommandHelpAction::performCall() { // print some general advice std::cout << std::endl << std::endl << "Usage help:" << std::endl; std::cout << "================================================================================" << std::endl; std::cout << "Usage: molecuilder -- [arguments] [-- ...]" << std::endl; std::cout << std::endl; std::cout << "MoleCuilder can do all kinds of measurements and manipulations and it always" << std::endl; std::cout << "works on files! See action 'input' and 'set-output' on how to specify these." << std::endl; std::cout << std::endl; std::cout << "To get a list of all actions, use " << std::endl; std::cout << "\t'molecuilder --help'." << std::endl; std::cout << "To get all options for a specific action, use " << std::endl; std::cout << "\t'molecuilder --help --actionname \"\"'." << std::endl; std::cout << std::endl; std::cout << "Arguments are given in the following (peculiar) ways:" << std::endl; std::cout << "\t - Boolean: give as 0 (false) or 1 (true)." << std::endl; std::cout << "\t - Integer: give as e.g. 17" << std::endl; std::cout << "\t - Double: give as e.g. 0.5346" << std::endl; std::cout << "\t - String: give as e.g. \"test\"" << std::endl; std::cout << "\t - List/vector of strings: gives as \"first\" \"second\" \"third\"." << std::endl; std::cout << "\t - Vector: give as \"x,y,z\", i.e. its 3 components." << std::endl; std::cout << "\t - Domain: give as \"xx,yx,yy,zx,zy,zz\", i.e. symmetric 3x3 matrix." << std::endl; std::cout << "\t - Path/filename: give as \"\"." << std::endl; std::cout << "================================================================================" << std::endl; std::cout << std::endl; // print list of actions or its options if (params.actionname.get() == std::string("none")) { // print list of all Actions std::cout << "Here is a list of all available Actions:" << std::endl; for(ActionRegistry::const_iterator iter = ActionRegistry::getInstance().getBeginIter(); iter != ActionRegistry::getInstance().getEndIter(); ++iter) { const Action *instance = iter->second; std::cout << "'" << iter->first << "': \t " << instance->Traits.getDescription() << std::endl; } } else { // retrieve command from Registry and print its help if (ActionRegistry::getInstance().isActionPresentByName(params.actionname.get())) { const Action *instance = ActionRegistry::getInstance().getActionByName(params.actionname.get()); // else give description of Action and its option value if present std::cout << instance->help(); std::cout << std::endl; std::cout << std::endl; } else { ELOG(1, "No action is known by the name " << params.actionname.get() << "."); return Action::failure; } } return Action::success; } Action::state_ptr CommandHelpAction::performUndo(Action::state_ptr _state) { return Action::success; } Action::state_ptr CommandHelpAction::performRedo(Action::state_ptr _state){ return Action::success; } bool CommandHelpAction::canUndo() { return true; } bool CommandHelpAction::shouldUndo() { return false; } /** =========== end of function ====================== */