aboutsummaryrefslogtreecommitdiff
path: root/bdep/argument-grouping.cxx
blob: b5796c0c02724f332af4f396b6f522c44a80e962 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// -*- C++ -*-
//
// This file was generated by CLI, a command line interface
// compiler for C++.
//

// Begin prologue.
//
#include <bdep/types-parsers.hxx>
//
// End prologue.

#include <bdep/argument-grouping.hxx>

#include <map>

namespace bdep
{
  ::bdep::cli::usage_para
  print_bdep_argument_grouping_usage (::std::ostream& os, ::bdep::cli::usage_para p)
  {
    CLI_POTENTIALLY_UNUSED (os);

    if (p != ::bdep::cli::usage_para::none)
      os << ::std::endl;

    os << "\033[1mSYNOPSIS\033[0m" << ::std::endl
       << ::std::endl
       << "\033[1mbdep\033[0m \033[1m{\033[0m \033[4moptions\033[0m \033[1m}+\033[0m \033[4margument\033[0m \033[1m+{\033[0m \033[4moptions\033[0m \033[1m}\033[0m\033[0m" << ::std::endl
       << ::std::endl
       << "\033[1mDESCRIPTION\033[0m" << ::std::endl
       << ::std::endl
       << "For certain commands certain options and command line variables can be grouped" << ::std::endl
       << "to only apply to specific arguments. This help topic describes the argument" << ::std::endl
       << "grouping facility used for this purpose." << ::std::endl
       << ::std::endl
       << "Groups can be specified before (leading) and/or after (trailing) the argument" << ::std::endl
       << "they apply to. A leading group starts with '\033[1m{\033[0m' and ends with '\033[1m}+\033[0m' while a" << ::std::endl
       << "trailing group starts with '\033[1m+{\033[0m' and ends with '\033[1m}\033[0m'. For example:" << ::std::endl
       << ::std::endl
       << "{ --foo --bar }+ arg   # 'arg' with '--foo' '--bar'" << ::std::endl
       << "arg +{ fox=1 baz=2 }   # 'arg' with 'fox=1' 'baz=2'" << ::std::endl
       << ::std::endl
       << "Multiple leading and/or trailing groups can be specified for the same argument." << ::std::endl
       << "For example:" << ::std::endl
       << ::std::endl
       << "{ -f }+ { -b }+ arg +{ f=1 } +{ b=2 } # 'arg' with '-f' 'b' 'f=1' 'b=2'" << ::std::endl
       << ::std::endl
       << "The group applies to a single argument only unless multiple arguments are" << ::std::endl
       << "themselves grouped with '\033[1m{\033[0m' and '\033[1m}\033[0m'. For example:" << ::std::endl
       << ::std::endl
       << "{ --foo }+ arg1  arg2 +{ --bar }      # 'arg1' with '--foo'" << ::std::endl
       << "                                      # 'arg2' with '--bar'" << ::std::endl
       << ::std::endl
       << "{ --foo }+ { arg1  arg2 } +{ --bar }  # 'arg1' with '--foo' '--bar'" << ::std::endl
       << "                                      # 'arg2' with '--foo' '--bar'" << ::std::endl
       << ::std::endl
       << "The group separators ('\033[1m{\033[0m', '\033[1m}+'\033[0m, etc) must be separate command line arguments." << ::std::endl
       << "In particular, they must not be adjacent either to the arguments inside the" << ::std::endl
       << "group nor to the argument they apply to. All such cases will be treated as" << ::std::endl
       << "ordinary arguments. For example:" << ::std::endl
       << ::std::endl
       << "{--foo}+ arg   # '{--foo}+' ..." << ::std::endl
       << "arg+{ --foo }  # 'arg+{' ..." << ::std::endl
       << ::std::endl
       << "If one of the group separators needs to be specified as an argument verbatim," << ::std::endl
       << "then it must be escaped with '\033[1m\\\033[0m'. For example:" << ::std::endl
       << ::std::endl
       << "}             # error: unexpected group separator" << ::std::endl
       << "}x            # '}x'" << ::std::endl
       << "\\}            # '}'" << ::std::endl
       << "{ \\}+ }+ arg  # 'arg' with '}+'" << ::std::endl;

    p = ::bdep::cli::usage_para::text;

    return p;
  }
}

// Begin epilogue.
//
//
// End epilogue.