#include <cstdio>
+#include <algorithm>
#include <map>
#include <string>
#include <utility>
const CommandLineModuleInterface &module) = 0;
};
+/********************************************************************
+ * HelpExportMan
+ */
+
+/*! \internal \brief
+ * Implements export for man pages.
+ *
+ * \ingroup module_commandline
+ */
+class HelpExportMan : public HelpExportInterface
+{
+ public:
+ virtual void exportModuleHelp(const std::string &tag,
+ const CommandLineModuleInterface &module);
+};
+
+void HelpExportMan::exportModuleHelp(const std::string &tag,
+ const CommandLineModuleInterface &module)
+{
+ File file("man1/" + tag + ".1", "w");
+
+ // TODO: It would be nice to remove the VERSION prefix from the version
+ // string to make it shorter.
+ file.writeLine(formatString(".TH %s 1 \"\" \"%s\" \"GROMACS Manual\"\n",
+ tag.c_str(),
+ GromacsVersion()));
+ file.writeLine(".SH NAME");
+ file.writeLine(formatString("%s - %s", tag.c_str(),
+ module.shortDescription()));
+ file.writeLine();
+
+ CommandLineHelpContext context(&file, eHelpOutputFormat_Man);
+ std::string displayName(tag);
+ std::replace(displayName.begin(), displayName.end(), '-', ' ');
+ context.setModuleDisplayName(displayName);
+ module.writeHelp(context);
+
+ file.writeLine(".SH SEE ALSO");
+ file.writeLine(".BR gromacs(7)");
+ file.writeLine();
+ file.writeLine("More information about \\fBGROMACS\\fR is available at <\\fIhttp://www.gromacs.org/\\fR>.");
+
+ file.close();
+}
+
} // namespace
/********************************************************************
if (!exportFormat.empty())
{
boost::scoped_ptr<HelpExportInterface> exporter;
+ if (exportFormat == "man")
+ {
+ exporter.reset(new HelpExportMan);
+ }
+ else
{
GMX_THROW(NotImplementedError("This help format is not implemented"));
}
case eHelpOutputFormat_Console:
type = "help";
break;
+ case eHelpOutputFormat_Man:
+ type = "nroff";
+ break;
default:
GMX_THROW(NotImplementedError(
"Command-line help is not implemented for this output format"));