@@ -3579,14 +3579,9 @@ operator & (group a, group b)
3579
3579
* where all single char flag params ("-a", "b", ...) are joinable
3580
3580
*
3581
3581
*****************************************************************************/
3582
- inline group&
3583
- joinable (group& param) {
3584
- return param.joinable (true );
3585
- }
3586
-
3587
- inline group&&
3588
- joinable (group&& param) {
3589
- return std::move (param.joinable (true ));
3582
+ inline group
3583
+ joinable (group g) {
3584
+ return g.joinable (true );
3590
3585
}
3591
3586
3592
3587
// -------------------------------------------------------------------
@@ -3676,16 +3671,16 @@ with_prefix(const arg_string& prefix, parameter&& p) {
3676
3671
3677
3672
// -------------------------------------------------------------------
3678
3673
inline group&
3679
- with_prefix (const arg_string& prefix, group& params )
3674
+ with_prefix (const arg_string& prefix, group& g )
3680
3675
{
3681
- for (auto & p : params ) {
3676
+ for (auto & p : g ) {
3682
3677
if (p.is_group ()) {
3683
3678
with_prefix (prefix, p.as_group ());
3684
3679
} else {
3685
3680
with_prefix (prefix, p.as_param ());
3686
3681
}
3687
3682
}
3688
- return params ;
3683
+ return g ;
3689
3684
}
3690
3685
3691
3686
@@ -3726,16 +3721,16 @@ with_prefixes_short_long(const arg_string& shortpfx, const arg_string& longpfx,
3726
3721
inline group&
3727
3722
with_prefixes_short_long (const arg_string& shortFlagPrefix,
3728
3723
const arg_string& longFlagPrefix,
3729
- group& params )
3724
+ group& g )
3730
3725
{
3731
- for (auto & p : params ) {
3726
+ for (auto & p : g ) {
3732
3727
if (p.is_group ()) {
3733
3728
with_prefixes_short_long (shortFlagPrefix, longFlagPrefix, p.as_group ());
3734
3729
} else {
3735
3730
with_prefixes_short_long (shortFlagPrefix, longFlagPrefix, p.as_param ());
3736
3731
}
3737
3732
}
3738
- return params ;
3733
+ return g ;
3739
3734
}
3740
3735
3741
3736
@@ -5356,17 +5351,17 @@ class usage_lines
5356
5351
public:
5357
5352
using string = doc_string;
5358
5353
5359
- usage_lines (const group& params , string prefix = " " ,
5354
+ usage_lines (const group& cli , string prefix = " " ,
5360
5355
const doc_formatting& fmt = doc_formatting{})
5361
5356
:
5362
- params_ (params ), fmt_(fmt), prefix_(std::move(prefix))
5357
+ cli_ (cli ), fmt_(fmt), prefix_(std::move(prefix))
5363
5358
{
5364
5359
if (!prefix_.empty ()) prefix_ += ' ' ;
5365
5360
if (fmt_.start_column () > 0 ) prefix_.insert (0 , fmt.start_column (), ' ' );
5366
5361
}
5367
5362
5368
- usage_lines (const group& params , const doc_formatting& fmt):
5369
- usage_lines (params , " " , fmt)
5363
+ usage_lines (const group& cli , const doc_formatting& fmt):
5364
+ usage_lines (cli , " " , fmt)
5370
5365
{}
5371
5366
5372
5367
usage_lines& ommit_outermost_group_surrounders (bool yes) {
@@ -5389,7 +5384,7 @@ class usage_lines
5389
5384
5390
5385
5391
5386
private:
5392
- const group& params_ ;
5387
+ const group& cli_ ;
5393
5388
doc_formatting fmt_;
5394
5389
string prefix_;
5395
5390
bool ommitOutermostSurrounders_ = false ;
@@ -5424,10 +5419,10 @@ class usage_lines
5424
5419
void print_usage (OStream& os) const
5425
5420
{
5426
5421
context cur;
5427
- cur.pos = params_ .begin_dfs ();
5422
+ cur.pos = cli_ .begin_dfs ();
5428
5423
cur.linestart = true ;
5429
5424
cur.level = cur.pos .level ();
5430
- cur.outermost = ¶ms_ ;
5425
+ cur.outermost = &cli_ ;
5431
5426
5432
5427
print_usage (os, cur, prefix_);
5433
5428
}
@@ -5651,33 +5646,33 @@ class usage_lines
5651
5646
* @brief prints flags in one group in a merged fashion
5652
5647
*
5653
5648
*******************************************************************/
5654
- string joined_label (const group& params , const context& cur) const
5649
+ string joined_label (const group& g , const context& cur) const
5655
5650
{
5656
5651
if (!fmt_.merge_alternative_flags_with_common_prefix () &&
5657
5652
!fmt_.merge_joinable_with_common_prefix ()) return " " ;
5658
5653
5659
- const bool flagsonly = std::all_of (params .begin (), params .end (),
5654
+ const bool flagsonly = std::all_of (g .begin (), g .end (),
5660
5655
[](const pattern& p){
5661
5656
return p.is_param () && !p.as_param ().flags ().empty ();
5662
5657
});
5663
5658
5664
5659
if (!flagsonly) return " " ;
5665
5660
5666
- const bool showOpt = params .all_optional () &&
5667
- !(ommitOutermostSurrounders_ && cur.outermost == ¶ms );
5661
+ const bool showOpt = g .all_optional () &&
5662
+ !(ommitOutermostSurrounders_ && cur.outermost == &g );
5668
5663
5669
- auto pfx = params .common_flag_prefix ();
5664
+ auto pfx = g .common_flag_prefix ();
5670
5665
if (pfx.empty ()) return " " ;
5671
5666
5672
5667
const auto n = pfx.size ();
5673
- if (params .exclusive () &&
5668
+ if (g .exclusive () &&
5674
5669
fmt_.merge_alternative_flags_with_common_prefix ())
5675
5670
{
5676
5671
string lbl;
5677
5672
if (showOpt) lbl += fmt_.optional_prefix ();
5678
5673
lbl += pfx + fmt_.alternatives_prefix ();
5679
5674
bool first = true ;
5680
- for (const auto & p : params ) {
5675
+ for (const auto & p : g ) {
5681
5676
if (p.is_param ()) {
5682
5677
if (first)
5683
5678
first = false ;
@@ -5691,10 +5686,10 @@ class usage_lines
5691
5686
return lbl;
5692
5687
}
5693
5688
// no alternatives, but joinable flags
5694
- else if (params .joinable () &&
5689
+ else if (g .joinable () &&
5695
5690
fmt_.merge_joinable_with_common_prefix ())
5696
5691
{
5697
- const bool allSingleChar = std::all_of (params .begin (), params .end (),
5692
+ const bool allSingleChar = std::all_of (g .begin (), g .end (),
5698
5693
[&](const pattern& p){
5699
5694
return p.is_param () &&
5700
5695
p.as_param ().flags ().front ().substr (n).size () == 1 ;
@@ -5704,7 +5699,7 @@ class usage_lines
5704
5699
string lbl;
5705
5700
if (showOpt) lbl += fmt_.optional_prefix ();
5706
5701
lbl += pfx;
5707
- for (const auto & p : params ) {
5702
+ for (const auto & p : g ) {
5708
5703
if (p.is_param ())
5709
5704
lbl += p.as_param ().flags ().front ().substr (n);
5710
5705
}
@@ -5833,11 +5828,11 @@ class documentation
5833
5828
usgFmt_.max_flags_per_param_in_doc ());
5834
5829
}
5835
5830
5836
- documentation (const group& params ,
5831
+ documentation (const group& cli ,
5837
5832
const param_filter& filter,
5838
5833
const doc_formatting& fmt = doc_formatting{})
5839
5834
:
5840
- documentation(params , fmt, filter)
5835
+ documentation(cli , fmt, filter)
5841
5836
{}
5842
5837
5843
5838
template <class OStream >
@@ -5868,20 +5863,20 @@ class documentation
5868
5863
*
5869
5864
*******************************************************************/
5870
5865
template <class OStream >
5871
- void print_doc (OStream& os, const group& params ,
5866
+ void print_doc (OStream& os, const group& cli ,
5872
5867
printed& sofar,
5873
5868
int indentLvl = 0 ) const
5874
5869
{
5875
- if (params .empty ()) return ;
5870
+ if (cli .empty ()) return ;
5876
5871
5877
5872
// if group itself doesn't have docstring
5878
- if (params .doc ().empty ()) {
5879
- for (const auto & p : params ) {
5873
+ if (cli .doc ().empty ()) {
5874
+ for (const auto & p : cli ) {
5880
5875
print_doc (os, p, sofar, indentLvl);
5881
5876
}
5882
5877
}
5883
5878
else { // group itself does have docstring
5884
- bool anyDocInside = std::any_of (params .begin (), params .end (),
5879
+ bool anyDocInside = std::any_of (cli .begin (), cli .end (),
5885
5880
[](const pattern& p){ return !p.doc ().empty (); });
5886
5881
5887
5882
if (anyDocInside) { // group docstring as title, then child entries
@@ -5890,19 +5885,19 @@ class documentation
5890
5885
}
5891
5886
auto indent = string (fmt_.start_column (), ' ' );
5892
5887
if (indentLvl > 0 ) indent += string (fmt_.indent_size () * indentLvl, ' ' );
5893
- os << indent << params .doc () << ' \n ' ;
5888
+ os << indent << cli .doc () << ' \n ' ;
5894
5889
sofar = printed::nothing;
5895
- for (const auto & p : params ) {
5890
+ for (const auto & p : cli ) {
5896
5891
print_doc (os, p, sofar, indentLvl + 1 );
5897
5892
}
5898
5893
sofar = printed::paragraph;
5899
5894
}
5900
5895
else { // group label first then group docstring
5901
- auto lbl = usage_lines (params , usgFmt_)
5896
+ auto lbl = usage_lines (cli , usgFmt_)
5902
5897
.ommit_outermost_group_surrounders (true ).str ();
5903
5898
5904
5899
str::trim (lbl);
5905
- print_entry (os, lbl, params .doc (), fmt_, sofar, indentLvl);
5900
+ print_entry (os, lbl, cli .doc (), fmt_, sofar, indentLvl);
5906
5901
}
5907
5902
}
5908
5903
}
@@ -6122,13 +6117,13 @@ class man_page
6122
6117
*
6123
6118
*****************************************************************************/
6124
6119
inline man_page
6125
- make_man_page (const group& params ,
6120
+ make_man_page (const group& cli ,
6126
6121
doc_string progname = " " ,
6127
6122
const doc_formatting& fmt = doc_formatting{})
6128
6123
{
6129
6124
man_page man;
6130
- man.append_section (" SYNOPSIS" , usage_lines (params ,progname,fmt).str ());
6131
- man.append_section (" OPTIONS" , documentation (params ,fmt).str ());
6125
+ man.append_section (" SYNOPSIS" , usage_lines (cli ,progname,fmt).str ());
6126
+ man.append_section (" OPTIONS" , documentation (cli ,fmt).str ());
6132
6127
return man;
6133
6128
}
6134
6129
0 commit comments