summaryrefslogtreecommitdiffstats
path: root/bdep/new.cli
blob: 5026d744ffb0a6840d4a7f0f3c75bf2c7f109a94 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
// file      : bdep/new.cli
// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

include <bdep/project.cli>;
include <bdep/new-types.hxx>;

"\section=1"
"\name=bdep-new"
"\summary=create and initialize new project"

namespace bdep
{
  {
    "<options> <spec> <name>
     <type> <type-opt>
     <lang> <lang-opt>
     <vcs> <vcs-opt>
     <cfg-name> <cfg-dir>
     <prj-spec> <prj-dir>
     <cfg-args> <option> <module> <cfg-var>",

    "\h|SYNOPSIS|

     \c{\b{bdep new} [<options>] [\b{--no-init}] <spec> <name>\n
        \b{bdep new} [<options>] \b{--config-add|-A} <cfg-dir> [\b{@}<cfg-name>] <spec> <name>\n
        \b{bdep new} [<options>] \b{--config-create|-C} <cfg-dir> [\b{@}<cfg-name>] <spec> <name>\n
        \ \ \ \ \ \ \ \ \ [<cfg-args>]\n
        \b{bdep new} [<options>] \b{--package} [<prj-spec>] <spec> <name>}

     \c{<spec> \ \ \ \ = [<type>] [<lang>] [<vcs>]\n
        <type> \ \ \ \ = \b{--type}|\b{-t} (\b{exe}|\b{lib}|\b{bare}|\b{empty})[\b{,}<type-opt>...]\n
        <lang> \ \ \ \ = \b{--lang}|\b{-l} (\b{c}|\b{c++})[\b{,}<lang-opt>...]\n
        <vcs> \ \ \ \ \ = \b{--vcs}|\b{-s} \ (\b{git}|\b{none})[\b{,}<vcs-opt>...]\n
        <prj-spec> = \b{--directory}|\b{-d} <prj-dir>\n
        <cfg-args> = (<option> | <module> | <cfg-var>)...}

     \h|DESCRIPTION|

     The \cb{new} command creates and initializes a new project (the first
     three forms) or a new package in an already existing project (the last
     form). All four forms first create according to <spec> a new \cb{build2}
     project/package called <name> in the <name> subdirectory of the current
     working directory (unless overridden with \c{\b{--output-dir}|\b{-o}}).
     See \l{bpkg#package-name Package Name} for details on project/package
     names.

     The first form then, unless the \cb{--no-init} option is specified,
     initializes an empty project database as if by executing the
     \l{bdep-init(1)} command with the \cb{--empty} option. Similarly, the
     second and third forms add an existing or create new build configuration
     and then initialize the project in that configuration as if by executing
     the \l{bdep-init(1)} command with the \cb{--config-add} or
     \cb{--config-create} option, respectively.

     The last form adds the new package to the \cb{packages.manifest} file
     creating it if necessary. If no project directory is explicitly specified
     with \c{\b{--directory}|\b{-d}}, then the current working directory is
     assumed. Note that nested packages are not allowed.

     The project parameters such as type (executable, library, etc), language,
     and version control system can be customized as described next. Some of
     these parameters also support parameter-specific options (such as the
     file extensions to use in a C++ project) that can be specified with a
     comma after the parameter value.

     The project type can be specified with the \c{\b{--type}|\b{-t}} option.
     Valid values for this option and their semantics are described next. If
     unspecified, an executable project is created by default.

     \dl|

     \li|\cb{exe}

         A project that builds a sample executable. Recognized executable
         project options:

         \cb{no-tests} \- Don't add support for functional/integration testing.

         \cb{unit-tests} \- Add support for unit testing.
         |

     \li|\cb{lib}

         A project that builds a sample library. Recognized library project
         options:

         \cb{no-tests} \- Don't add support for functional/integration testing.

         \cb{unit-tests} \- Add support for unit testing.
         |

     \li|\cb{bare}

         A project without any source code. Recognized bare project options:

         \cb{no-tests} \- Don't add support for testing.
         |

     \li|\cb{empty}

         An empty project that can be filled with packages (see
         \cb{--package}). Note that the project language is ignored for
         this project type.||

     The project language can be specified with the \c{\b{--lang}|\b{-l}}
     option. Valid values for this option and their semantics are described
     next. If unspecified, a C++ project is created by default.

     \dl|

     \li|\cb{c}

         A C project.|

     \li|\cb{c++}

         A C++ project. Recognized language options:

         \cb{cxx} \- Use the \cb{.cxx}, \cb{.hxx}, \cb{.ixx}, \cb{.txx}, and
         \cb{.mxx} source file extensions (default).

         \cb{cpp} \- Use the \cb{.cpp}, \cb{.hpp}, \cb{.ipp}, \cb{.tpp}, and
         \cb{.mpp} source file extensions.

         \cb{binless} \- Create a header-only library.||

     The project version control system can be specified with the
     \c{\b{--vcs}|\b{-s}} option. Valid values for this option and their
     semantics are described next. If unspecified, \cb{git} is assumed by
     default.

     \dl|

     \li|\cb{git}

         Initialize a \cb{git(1)} repository inside the project and generate
         \cb{.gitignore} files.|

     \li|\cb{none}

         Don't initialize a version control system inside the project.||
     "
  }

  //--type options
  //
  class cmd_new_exe_options
  {
    bool no-tests;
    bool unit-tests;
  };

  class cmd_new_lib_options
  {
    bool no-tests;
    bool unit-tests;
  };

  class cmd_new_bare_options
  {
    bool no-tests;
  };

  class cmd_new_empty_options
  {
  };

  // --lang options
  //
  class cmd_new_c_options
  {
  };

  class cmd_new_cxx_options
  {
    bool cpp;
    bool cxx;
    bool binless;
  };

  // --vcs options
  //
  class cmd_new_git_options
  {
  };

  class cmd_new_none_options
  {
  };

  class cmd_new_options: configuration_add_options, configuration_name_options
  {
    "\h|NEW OPTIONS|"

    bool --no-init
    {
      "Don't initialize an empty build configuration set."
    }

    bool --package
    {
      "Create a package inside an already existing project rather than a
       new project."
    }

    dir_path --output-dir|-o
    {
      "<dir>",
      "Create the project in the specified directory."
    }

    dir_path --directory|-d
    {
      "<dir>",
      "Assume the project is in the specified directory rather than in the
       current working directory. Only used with \cb{--package}."
    }

    cmd_new_type --type|-t
    {
      "<type>[,<opt>...]",
      "Specify project type and options. Valid values for <type> are \cb{exe}
       (executable project, default), \cb{lib} (library project), \cb{bare}
       (bare project without any source code), and \cb{empty} (empty project
       ready to be filled with packages). Valid values for <opt> are
       type-specific."
    }

    cmd_new_lang --lang|-l
    {
      "<lang>[,<opt>...]",
      "Specify project language and options. Valid values for <lang> are \cb{c}
       and \cb{c++} (default). Valid values for <opt> are language-specific."
    }

    cmd_new_vcs --vcs|-s
    {
      "<vcs>[,<opt>...]",
      "Specify project version control system and options. Valid values for
       <vcs> are \cb{git} (default) and \cb{none}. Valid values for <opt> are
       system-specific."
    }

    bool --no-amalgamation
    {
      "Create a project with disabled amalgamation support. This option is
       normally only used for testing."
    }

    bool --no-checks
    {
      "Suppress nested project/package checks. This option is normally only
       used for testing."
    }

    dir_path --config-add|-A
    {
      "<dir>",
      "Add an existing build configuration <dir>."
    }

    dir_path --config-create|-C
    {
      "<dir>",
      "Create a new build configuration in <dir>."
    }
  };

  "\h|ENVIRONMENT|

   The \cb{BDEP_AUTHOR_EMAIL} environment variable can be used to specify the
   package email address. If not set, the \cb{new} command will first try to
   obtain the email from the version control system (if used) and then from
   the \cb{EMAIL} environment variable. If all these methods fail, a dummy
   \cb{@example.org} email is used.
  "
}