Make [PROGRAM] replacement respect the binary name passed to
CommandLineModuleManager, giving the tests full control over the help
output.
There are complications making this work nicely in the selection help
(requires some effort in propagating the information), so change the
wording there for now to avoid this tag. Can be revisited at a later
time if/when the help writing context is more uniform for different
cases that can trigger the selection help ('gmx help ...' vs. 'help ...'
in the selection prompt).
Change-Id: I93e7dd8279d3730d38122c212174e533420859b9
};
CommandLineHelpContext::CommandLineHelpContext(
};
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_(new Impl(file, format, links))
{
+ impl_->writerContext_.setReplacement("[PROGRAM]", programName);
}
CommandLineHelpContext::CommandLineHelpContext(
}
CommandLineHelpContext::CommandLineHelpContext(
#ifndef GMX_COMMANDLINE_CMDLINEHELPCONTEXT_H
#define GMX_COMMANDLINE_CMDLINEHELPCONTEXT_H
#ifndef GMX_COMMANDLINE_CMDLINEHELPCONTEXT_H
#define GMX_COMMANDLINE_CMDLINEHELPCONTEXT_H
#include "gromacs/onlinehelp/helpwritercontext.h"
#include "gromacs/utility/classhelpers.h"
#include "gromacs/onlinehelp/helpwritercontext.h"
#include "gromacs/utility/classhelpers.h"
* Wraps the constructor of HelpWriterContext.
*/
CommandLineHelpContext(File *file, HelpOutputFormat format,
* 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
//! 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:");
// 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>'.");
}
context.writeTextBlock("To access the help, use '[PROGRAM] help <topic>'.");
context.writeTextBlock("For help on a command, use '[PROGRAM] help <command>'.");
}
- CommandLineHelpContext context(&file, eHelpOutputFormat_Rst, &links_);
+ CommandLineHelpContext context(&file, eHelpOutputFormat_Rst, &links_, binaryName_);
context.enterSubSection(displayName);
context.setModuleDisplayName(displayName);
module.writeHelp(context);
context.enterSubSection(displayName);
context.setModuleDisplayName(displayName);
module.writeHelp(context);
void HelpExportReStructuredText::exportTopic(const HelpTopicInterface &topic)
{
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();
}
manager.writeCurrentTopic();
}
File &outputFile = impl_->outputRedirector_->standardOutput();
HelpLinks links(eHelpOutputFormat_Console);
initProgramLinks(&links, *impl_);
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)
{
context.setShowHidden(impl_->bHidden_);
if (impl_->moduleOverride_ != NULL)
{
/*
* This file is part of the GROMACS molecular simulation package.
*
/*
* 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.
* 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");
{
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();
context.setShowHidden(bHidden_);
writer->writeHelp(context);
file.close();
test commands
-------------
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>
.. include:: /fragments/bytopic-man.rst
]]></String>
Additional help is available on the following topics:
commands List of available commands
topic Test topic
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>
]]></String>
</ReferenceData>
Impl(const StatePointer &state, int sectionDepth)
: state_(state), sectionDepth_(sectionDepth)
{
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)
//! Adds a new replacement.
void addReplacement(const std::string &search,
const std::string &replace)
GMX_DISALLOW_ASSIGN(Impl);
};
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);
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",
"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",
"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)
{
//! 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(),
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);
}
CommandLineHelpWriter(options).writeHelp(context);
}