Boost C++ Libraries: Ticket #6114: Program options help message do not align across multiple groups https://svn.boost.org/trac10/ticket/6114 <p> libs/program_options/src/options_description.cpp contains code to line up the description strings if the length of the options column &gt; 23. </p> <p> However, this does not take different groups into account. The patch gets the column lengths from the subgroups as well. </p> <p> Current situation: </p> <pre class="wiki">Overall: Option group 1: --opt1 Short option 1 --option 2 Short option 2 ^ Aligned here Option group 2: --much_longer_option arg Misaligned description in 2nd group if option column length &gt; magic 23 character limit ^ Aligned here </pre><p> Patched: </p> <pre class="wiki">Overall: Option group 1: --opt1 Short option 1 --option 2 Short option 2 ^ Aligned here Option group 2: --much_longer_option arg Misaligned description in 2nd group if option column length &gt; magic 23 character limit ^ Aligned here </pre><p> is produced by this minimal program </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/program_options.hpp&gt;</span><span class="cp"></span> <span class="k">namespace</span> <span class="n">po</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">program_options</span><span class="p">;</span> <span class="kt">int</span> <span class="nf">main</span> <span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span><span class="n">argv</span><span class="p">[])</span> <span class="p">{</span> <span class="c1">// 1st group</span> <span class="n">po</span><span class="o">::</span><span class="n">options_description</span> <span class="n">groups1</span> <span class="p">(</span><span class="s">&quot;Option group 1&quot;</span><span class="p">);</span> <span class="n">groups1</span><span class="p">.</span><span class="n">add_options</span><span class="p">()</span> <span class="p">(</span><span class="s">&quot;opt1&quot;</span><span class="p">,</span> <span class="s">&quot;Short option 1&quot;</span><span class="p">)</span> <span class="p">(</span><span class="s">&quot;option 2&quot;</span><span class="p">,</span> <span class="s">&quot;Short option 2</span><span class="se">\n</span><span class="s">^</span><span class="se">\n</span><span class="s">Aligned here&quot;</span><span class="p">);</span> <span class="c1">// 2nd group</span> <span class="n">po</span><span class="o">::</span><span class="n">options_description</span> <span class="n">groups2</span> <span class="p">(</span><span class="s">&quot;Option group 2&quot;</span><span class="p">);</span> <span class="n">groups2</span><span class="p">.</span><span class="n">add_options</span><span class="p">()</span> <span class="p">(</span><span class="s">&quot;much_longer_option&quot;</span><span class="p">,</span> <span class="n">po</span><span class="o">::</span><span class="n">value</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span><span class="p">(),</span> <span class="s">&quot;Misaligned description in 2nd group if option &quot;</span> <span class="s">&quot;column length &gt; magic 23 character limit</span><span class="se">\n</span><span class="s">^</span><span class="se">\n</span><span class="s">&quot;</span> <span class="s">&quot;Aligned here&quot;</span><span class="p">);</span> <span class="n">po</span><span class="o">::</span><span class="n">options_description</span> <span class="n">cmdline_args</span><span class="p">(</span><span class="s">&quot;Overall&quot;</span><span class="p">);</span> <span class="n">cmdline_args</span><span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="n">groups1</span><span class="p">);</span> <span class="n">cmdline_args</span><span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="n">groups2</span><span class="p">);</span> <span class="n">std</span><span class="o">::</span><span class="n">cerr</span> <span class="o">&lt;&lt;</span> <span class="n">cmdline_args</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">;</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6114 Trac 1.4.3 Leo Goodstadt <boost@…> Fri, 11 Nov 2011 12:25:13 GMT attachment set https://svn.boost.org/trac10/ticket/6114 https://svn.boost.org/trac10/ticket/6114 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main.cpp</span> </li> </ul> <p> test case </p> Ticket Leo Goodstadt <boost@…> Fri, 11 Nov 2011 12:25:35 GMT attachment set https://svn.boost.org/trac10/ticket/6114 https://svn.boost.org/trac10/ticket/6114 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">svn_diff.txt</span> </li> </ul> <p> patch </p> Ticket boost@… Sat, 20 Apr 2013 14:11:27 GMT <link>https://svn.boost.org/trac10/ticket/6114#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6114#comment:1</guid> <description> <p> This "bug" seems to be still present on boost 1.49.0. It would be great if this patch could be checked / pushed by someone. It's not a major issue to have unaligned options but still, it would looks much better if they were. </p> </description> <category>Ticket</category> </item> <item> <author>TonyELewis@…</author> <pubDate>Tue, 05 Nov 2013 18:34:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6114#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6114#comment:2</guid> <description> <p> I would also really appreciate someone qualified assessing this relatively simple patch because this issue is making my Boost.Program_options (1.54.0) interface look much less professional. Thanks very much. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Vladimir Prus</dc:creator> <pubDate>Wed, 06 Nov 2013 09:23:15 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6114#comment:3 https://svn.boost.org/trac10/ticket/6114#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/86571" title="Align columns across groups in --help output. Patch from Leo ...">[86571]</a>) Align columns across groups in --help output. </p> <p> Patch from Leo Goodstadt. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6114" title="#6114: Patches: Program options help message do not align across multiple groups (closed: fixed)">#6114</a>. </p> Ticket Vladimir Prus Wed, 06 Nov 2013 09:25:05 GMT <link>https://svn.boost.org/trac10/ticket/6114#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6114#comment:4</guid> <description> <p> I've checked in to trunk, sorry it took so long, and also for missing 1.55 release. </p> <p> I've set a reminder to merge to release branch, although I don't know what that would mean in the git world, but hopefully will figure out. </p> </description> <category>Ticket</category> </item> <item> <author>TonyELewis@…</author> <pubDate>Wed, 06 Nov 2013 12:13:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6114#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6114#comment:5</guid> <description> <p> Fantastic! Thank you very much. </p> </description> <category>Ticket</category> </item> </channel> </rss>