};
CommandLineHelpContext::CommandLineHelpContext(
- File *file, HelpOutputFormat format, const HelpLinks *links)
+ File *file, HelpOutputFormat format, const HelpLinks *links,
+ const std::string &programName)
: impl_(new Impl(file, format, links))
{
+ impl_->writerContext_.setReplacement("[PROGRAM]", programName);
}
CommandLineHelpContext::CommandLineHelpContext(
#ifndef GMX_COMMANDLINE_CMDLINEHELPCONTEXT_H
#define GMX_COMMANDLINE_CMDLINEHELPCONTEXT_H
+#include <string>
+
#include "gromacs/onlinehelp/helpwritercontext.h"
#include "gromacs/utility/classhelpers.h"
* Wraps the constructor of HelpWriterContext.
*/
CommandLineHelpContext(File *file, HelpOutputFormat format,
- const HelpLinks *links);
+ const HelpLinks *links,
+ const std::string &programName);
//! Creates a context for a particular HelpWriterContext.
explicit CommandLineHelpContext(const HelpWriterContext &writerContext);
/*! \brief
// to determine such a set...
writeSubTopicList(context,
"Additional help is available on the following topics:");
- // TODO: Make these respect the binary name passed in, to make tests work better.
context.writeTextBlock("To access the help, use '[PROGRAM] help <topic>'.");
context.writeTextBlock("For help on a command, use '[PROGRAM] help <command>'.");
}
}
file.writeLine();
- CommandLineHelpContext context(&file, eHelpOutputFormat_Rst, &links_);
+ CommandLineHelpContext context(&file, eHelpOutputFormat_Rst, &links_, binaryName_);
context.enterSubSection(displayName);
context.setModuleDisplayName(displayName);
module.writeHelp(context);
void HelpExportReStructuredText::exportTopic(const HelpTopicInterface &topic)
{
- const std::string path("onlinehelp/" + std::string(topic.name()) + ".rst");
- File file(outputRedirector_->openFileForWriting(path));
- HelpWriterContext context(&file, eHelpOutputFormat_Rst, &links_);
- HelpManager manager(topic, context);
+ const std::string path("onlinehelp/" + std::string(topic.name()) + ".rst");
+ File file(outputRedirector_->openFileForWriting(path));
+ CommandLineHelpContext context(&file, eHelpOutputFormat_Rst, &links_,
+ binaryName_);
+ HelpManager manager(topic, context.writerContext());
manager.writeCurrentTopic();
}
File &outputFile = impl_->outputRedirector_->standardOutput();
HelpLinks links(eHelpOutputFormat_Console);
initProgramLinks(&links, *impl_);
- CommandLineHelpContext context(&outputFile, eHelpOutputFormat_Console, &links);
+ CommandLineHelpContext context(&outputFile, eHelpOutputFormat_Console, &links,
+ impl_->binaryName_);
context.setShowHidden(impl_->bHidden_);
if (impl_->moduleOverride_ != NULL)
{
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
{
std::string filename = tempFiles_.getTemporaryFilePath("helptext.txt");
gmx::File file(filename, "w");
- gmx::CommandLineHelpContext context(&file, gmx::eHelpOutputFormat_Console, NULL);
+ gmx::CommandLineHelpContext context(&file, gmx::eHelpOutputFormat_Console,
+ NULL, "test");
context.setShowHidden(bHidden_);
writer->writeHelp(context);
file.close();
test commands
-------------
-The following commands are available. Please refer to their individual man pages or ``commandline-test help <command>`` for further details.
+The following commands are available. Please refer to their individual man pages or ``test help <command>`` for further details.
.. include:: /fragments/bytopic-man.rst
]]></String>
Additional help is available on the following topics:
commands List of available commands
topic Test topic
-To access the help, use 'commandline-test help <topic>'.
-For help on a command, use 'commandline-test help <command>'.
+To access the help, use 'test help <topic>'.
+For help on a command, use 'test help <command>'.
]]></String>
</ReferenceData>
Impl(const StatePointer &state, int sectionDepth)
: state_(state), sectionDepth_(sectionDepth)
{
- initDefaultReplacements();
}
- //! Initializes default replacements for the chosen output format.
- void initDefaultReplacements();
//! Adds a new replacement.
void addReplacement(const std::string &search,
const std::string &replace)
GMX_DISALLOW_ASSIGN(Impl);
};
-void HelpWriterContext::Impl::initDefaultReplacements()
-{
- const char *program = getProgramContext().programName();
- addReplacement("[PROGRAM]", program);
-}
-
std::string HelpWriterContext::Impl::replaceLinks(const std::string &input) const
{
std::string result(input);
"if they are complex or for scripting.[PAR]",
"Each tool has different command-line arguments for specifying selections",
- "(listed by [TT][PROGRAM] help <tool>[tt]).",
+ "(see the help for the individual tools).",
"You can either pass a single string containing all selections (separated",
"by semicolons), or multiple strings, each containing one selection.",
"Note that you need to quote the selections to protect them from the",
//! Prints the command-line options for the unit test binary.
void printHelp(const Options &options)
{
+ const std::string &program = getProgramContext().displayName();
std::fprintf(stderr,
"\nYou can use the following GROMACS-specific command-line flags\n"
"to control the behavior of the tests:\n\n");
CommandLineHelpContext context(&File::standardError(),
- eHelpOutputFormat_Console, NULL);
- context.setModuleDisplayName(getProgramContext().displayName());
+ eHelpOutputFormat_Console, NULL, program);
+ context.setModuleDisplayName(program);
CommandLineHelpWriter(options).writeHelp(context);
}