- Add brackets for cases where the file name is actually optional.
- Add [...] for cases where multiple file names can be specified.
As supporting changes, extend the options machinery to be able to get
this information for the options, and fix an issue in the table
formatter that was causing some ugly formatting.
Related to #969.
Change-Id: I5b38d7ac6d7c58c3decce64ddfe60fff0a5797ed
{
type += bAbbrev ? ", Lib." : ", Library";
}
- // TODO: Add a tag for options that accept multiple files.
return type;
}
{
const bool bAbbrev = (context.outputFormat() == eHelpOutputFormat_Console);
std::string value("<" + option.type() + ">");
+ if (option.maxValueCount() != 1)
+ {
+ value += " [...]";
+ }
+ if (option.minValueCount() == 0)
+ {
+ value = "[" + value + "]";
+ }
std::string defaultValue(defaultOptionValue(option));
std::string info = "(" + fileOptionFlagsAsString(option, bAbbrev) + ")";
if (!defaultValue.empty())
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014, 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.
.description("Input file description")
.filetype(eftTrajectory).inputFile().required()
.defaultBasename("traj"));
+ options.addOption(FileNameOption("mult")
+ .description("Multiple file description")
+ .filetype(eftTrajectory).inputFile().multiValue()
+ .defaultBasename("traj"));
options.addOption(FileNameOption("lib")
.description("Library file description")
.filetype(eftGenericData).inputFile().libraryFile()
File name option with a long value: xtc trr cpt trj gro g96 pdb g87 tng
-f2 <.xtc/.trr/...> (path/to/long/trajectory.xtc) (Input)
File name option with a long value: xtc trr cpt trj gro g96 pdb g87 tng
- -lib <.xtc/.trr/...> (path/to/long/trajectory/name.xtc) (Input, Opt., Lib.) File name option with a long value and type: xtc trr cpt trj gro g96 pdb g87 tng
- -longfileopt <.dat> (deffile.dat) (Input, Opt.)
+ -lib [<.xtc/.trr/...>] (path/to/long/trajectory/name.xtc) (Input, Opt., Lib.)
+ File name option with a long value and type: xtc trr cpt trj gro g96 pdb
+ g87 tng
+ -longfileopt [<.dat>] (deffile.dat) (Input, Opt.)
File name option with a long name
- -longfileopt2 <.dat> (path/to/long/file/name.dat) (Input, Opt., Lib.)
+ -longfileopt2 [<.dat>] (path/to/long/file/name.dat) (Input, Opt., Lib.)
File name option with multiple long fields
]]></String>
-f <.xtc/.trr/...> (traj.xtc) (Input)
Input file description: xtc trr cpt trj gro g96 pdb g87 tng
- -lib <.dat> (libdata.dat) (Input, Opt., Lib.) Library file description
- -io <.dat> (inout.dat) (In/Out, Opt.) Input/Output file description
+ -mult [<.xtc/.trr/...> [...]] (traj.xtc) (Input, Opt.)
+ Multiple file description: xtc trr cpt trj gro g96 pdb g87 tng
+ -lib [<.dat>] (libdata.dat) (Input, Opt., Lib.) Library file description
+ -io [<.dat>] (inout.dat) (In/Out, Opt.) Input/Output file description
-o <.xvg> (Output, Opt.) Output file description
OPTIONS
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014, 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.
const int overflow = static_cast<int>(lines[line].length()) - currentWidth;
if (overflow > 0)
{
- if (overflow > columnWidth)
+ if (overflow > columnWidth && column->bWrap_)
{
columnLines.push_back(std::string());
continue;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014, 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.
formatter_.setColumnFirstLineOffset(2, 2);
formatter_.addColumnLine(3, g_wrapText2);
checkText(formatter_.formatRow(), "FormattedRow3");
+ // Test a case where a column value overflows even the next column.
+ formatter_.addColumnLine(0, "foobarfoobar");
+ formatter_.addColumnLine(1, "barfoobarfoo");
+ formatter_.addColumnLine(2, g_wrapText);
+ formatter_.addColumnLine(3, g_wrapText2);
+ checkText(formatter_.formatRow(), "FormattedRow4");
}
TEST_F(TextTableFormatterTest, HandlesLastColumnFolding)
A quick brown over the lazy
fox jumps over dog
the lazy dog
+]]></String>
+ <String Name="FormattedRow4"><![CDATA[
+foobarfoobar barfoobarfoo A quick brown
+ A quick brown fox jumps
+ fox jumps over over the lazy
+ the lazy dog dog
]]></String>
</ReferenceData>
return option().isRequired();
}
+int OptionInfo::minValueCount() const
+{
+ if (option().defaultValueIfSetExists())
+ {
+ return 0;
+ }
+ return option().minValueCount();
+}
+
+int OptionInfo::maxValueCount() const
+{
+ return option().maxValueCount();
+}
+
const std::string &OptionInfo::name() const
{
return option().name();
return description;
}
+std::string OptionInfo::formatDefaultValueIfSet() const
+{
+ return option().formatDefaultValueIfSet();
+}
+
int OptionInfo::valueCount() const
{
return option().valueCount();
return option().formatValue(i);
}
-std::string OptionInfo::formatDefaultValueIfSet() const
-{
- return option().formatDefaultValueIfSet();
-}
-
} // namespace gmx
bool isHidden() const;
//! Returns true if the option is required.
bool isRequired() const;
+ //! Returns the minimum number of values that this option accepts.
+ int minValueCount() const;
+ //! Returns the maximum number of values that this option accepts.
+ int maxValueCount() const;
//! Returns the name of the option.
const std::string &name() const;
//! Returns the type of the option as a string.
std::string type() const;
//! Returns the description of the option.
std::string formatDescription() const;
- //! Returns the number of values given for the option.
- int valueCount() const;
- //! Returns the i'th value of the option as a string.
- std::string formatValue(int i) const;
/*! \brief
* Returns the default value if set for the option as a string.
*
*/
std::string formatDefaultValueIfSet() const;
+ //! Returns the number of values given for the option.
+ int valueCount() const;
+ //! Returns the i'th value of the option as a string.
+ std::string formatValue(int i) const;
+
protected:
/*! \cond libapi */
/*! \brief
//! Returns the description of the option set by the calling code.
const std::string &description() const { return descr_; }
+ //! Returns true if defaultValueIfSet() value is specified.
+ bool defaultValueIfSetExists() const
+ { return hasFlag(efOption_DefaultValueIfSetExists); }
+ //! Returns the minimum number of values required in one set.
+ int minValueCount() const { return minValueCount_; }
+ //! Returns the maximum allowed number of values in one set (-1 = no limit).
+ int maxValueCount() const { return maxValueCount_; }
+
/*! \brief
* Returns an option info object corresponding to this option.
*/
//! Clears the given flag.
void clearFlag(OptionFlag flag) { return flags_.clear(flag); }
- //! Returns the minimum number of values required in one set.
- int minValueCount() const { return minValueCount_; }
- //! Returns the maximum allowed number of values in one set (-1 = no limit).
- int maxValueCount() const { return maxValueCount_; }
/*! \brief
* Sets a new minimum number of values required in one set.
*
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2014, 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.
//! The current value of the option is a programmatic default value.
efOption_HasDefaultValue = 1<<1,
//! An explicit default value has been provided for the option.
- efOption_ExplicitDefaultValue = 1<<2,
+ efOption_ExplicitDefaultValue = 1<<2,
/*! \brief
* Next assignment to the option clears old values.
*
* \see AbstractOption::setVector()
*/
efOption_Vector = 1<<8,
+ //! %Option has a defaultValueIfSet() specified.
+ efOption_DefaultValueIfSetExists = 1<<11,
//! %Option does not support default values.
efOption_NoDefaultValue = 1<<9,
/*! \brief
{
GMX_THROW(APIError("defaultValueIfSet() is not supported with allowMultiple()"));
}
+ setFlag(efOption_DefaultValueIfSetExists);
defaultValueIfSet_.reset(new T(value));
}