MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cpp-samples / ParseArguments

Function ParseArguments

pubsub-open-telemetry/parse_args.cc:27–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25namespace po = ::boost::program_options;
26
27ParseResult ParseArguments(int argc, char* argv[]) {
28 po::positional_options_description positional;
29 positional.add("project-id", 1);
30 positional.add("topic-id", 2);
31 po::options_description desc(
32 "A simple publisher application with Open Telemetery enabled");
33 // The following empty line comments are for readability.
34 desc.add_options()
35 //
36 ("help,h", "produce help message")
37 //
38 ("project-id", po::value<std::string>()->required(),
39 "the name of the Google Cloud project")
40 //
41 ("topic-id", po::value<std::string>()->required(),
42 "the name of the Google Cloud topic")
43 // Tracing options
44 ("tracing-rate", po::value<double>()->default_value(1.0),
45 "otel::BasicTracingRateOption value")
46 // Processor options
47 ("max-queue-size", po::value<int>()->default_value(2048),
48 "set the max queue size for open telemetery")
49 // Message options
50 ("message-count,n", po::value<int>()->default_value(1),
51 "the number of messages to publish")
52 //
53 ("message-size", po::value<int>()->default_value(1),
54 "the desired message payload size")
55 // Flow control options
56 ("max-pending-messages", po::value<std::size_t>(),
57 "pubsub::MaxPendingMessagesOption value")
58 //
59 ("max-pending-bytes", po::value<std::size_t>(),
60 "pubsub::MaxPendingBytesOption value")
61 //
62 ("publisher-action", po::value<std::string>(),
63 "pubsub::FullPublisherAction value "
64 "(block|ignore|reject)")
65 // Batching options
66 ("max-hold-time", po::value<int>(),
67 "pubsub::MaxHoldTimeOption value in us")
68 //
69 ("max-batch-bytes", po::value<std::size_t>(),
70 "pubsub::MaxBatchBytesOption value")
71 //
72 ("max-batch-messages", po::value<std::size_t>(),
73 "pubsub::MaxBatchMessagesOption value");
74
75 po::variables_map vm;
76 po::store(po::command_line_parser(argc, argv)
77 .options(desc)
78 .positional(positional)
79 .run(),
80 vm);
81
82 ParseResult result;
83 if (vm.count("help") || argc == 1) {
84 std::cerr << "Usage: " << argv[0] << " <project-id> <topic-id>\n";

Callers 4

mainFunction · 0.70
mainFunction · 0.70
mainFunction · 0.70
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected