Consistency in namespace-closing comments
[folly.git] / folly / experimental / test / NestedCommandLineAppTestHelper.cpp
1 /*
2  * Copyright 2017 Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <folly/experimental/NestedCommandLineApp.h>
18 #include <folly/portability/GFlags.h>
19
20 DEFINE_int32(global_foo, 42, "Global foo");
21
22 namespace po = ::boost::program_options;
23
24 namespace {
25
26 void init(const std::string& cmd,
27           const po::variables_map& /* options */,
28           const std::vector<std::string>& /* args */) {
29   printf("running %s\n", cmd.c_str());
30 }
31
32 void foo(const po::variables_map& options,
33          const std::vector<std::string>& args) {
34   printf("foo global-foo %d\n", options["global-foo"].as<int32_t>());
35   printf("foo local-foo %d\n", options["local-foo"].as<int32_t>());
36   for (auto& arg : args) {
37     printf("foo arg %s\n", arg.c_str());
38   }
39 }
40
41 } // namespace
42
43 int main(int argc, char *argv[]) {
44   folly::NestedCommandLineApp app("", "0.1", "", "", init);
45   app.addGFlags();
46   app.addCommand("foo", "[args...]", "Do some foo", "Does foo", foo)
47     .add_options()
48       ("local-foo", po::value<int32_t>()->default_value(42), "Local foo");
49   app.addAlias("bar", "foo");
50   app.addAlias("baz", "bar");
51   return app.run(argc, argv);
52 }