* \author Teemu Murtola <teemu.murtola@gmail.com>
* \ingroup module_commandline
*/
-#include "gromacs/commandline/cmdlineinit.h"
+#include "gmxpre.h"
+
+#include "cmdlineinit.h"
+
+#include "config.h"
#include <cstring>
#include <boost/scoped_ptr.hpp>
+#include "gromacs/commandline/cmdlinemodulemanager.h"
+#include "gromacs/commandline/cmdlineprogramcontext.h"
#include "gromacs/legacyheaders/network.h"
-#include "gromacs/legacyheaders/smalloc.h"
#include "gromacs/legacyheaders/types/commrec.h"
-
-#include "gromacs/commandline/cmdlineprogramcontext.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/init.h"
#include "gromacs/utility/programcontext.h"
+#include "gromacs/utility/smalloc.h"
namespace gmx
{
//! \addtogroup module_commandline
//! \{
-//! Global instance of ProgramInfo initialized in initForCommandLine().
-boost::scoped_ptr<ProgramInfo> g_commandLineContext;
+//! Global context instance initialized in initForCommandLine().
+boost::scoped_ptr<CommandLineProgramContext> g_commandLineContext;
#ifdef GMX_LIB_MPI
void broadcastArguments(const t_commrec *cr, int *argc, char ***argv)
} // namespace
-ProgramInfo &initForCommandLine(int *argc, char ***argv)
+CommandLineProgramContext &initForCommandLine(int *argc, char ***argv)
{
gmx::init(argc, argv);
GMX_RELEASE_ASSERT(!g_commandLineContext,
#endif
try
{
- g_commandLineContext.reset(new ProgramInfo(*argc, *argv));
+ g_commandLineContext.reset(new CommandLineProgramContext(*argc, *argv));
setProgramContext(g_commandLineContext.get());
}
catch (const std::exception &ex)
g_commandLineContext.reset();
}
+int runCommandLineModule(int argc, char *argv[],
+ CommandLineModuleInterface *module)
+{
+ return gmx::CommandLineModuleManager::runAsMainSingleModule(argc, argv, module);
+}
+
} // namespace gmx
+
+int gmx_run_cmain(int argc, char *argv[], int (*mainFunction)(int, char *[]))
+{
+ return gmx::CommandLineModuleManager::runAsMainCMain(argc, argv, mainFunction);
+}