Skip to content

Commit

Permalink
Parse command-line args (grpc#26161)
Browse files Browse the repository at this point in the history
  • Loading branch information
yashykt authored May 4, 2021
1 parent 1c49176 commit a8ebadb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/cpp/helloworld/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ cc_binary(
"//:grpc++",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
],
)

Expand Down Expand Up @@ -86,5 +87,6 @@ cc_binary(
"//:grpcpp_admin",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
],
)
2 changes: 2 additions & 0 deletions examples/cpp/helloworld/xds_greeter_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string>

#include "absl/flags/flag.h"
#include "absl/flags/parse.h"

#include <grpcpp/grpcpp.h>

Expand Down Expand Up @@ -77,6 +78,7 @@ class GreeterClient {
};

int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
GreeterClient greeter(grpc::CreateChannel(
absl::GetFlag(FLAGS_target), absl::GetFlag(FLAGS_secure)
? grpc::experimental::XdsCredentials(
Expand Down
2 changes: 2 additions & 0 deletions examples/cpp/helloworld/xds_greeter_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string>

#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/strings/str_cat.h"

#include <grpcpp/ext/admin_services.h>
Expand Down Expand Up @@ -101,6 +102,7 @@ void RunServer() {
}

int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
RunServer();
return 0;
}

0 comments on commit a8ebadb

Please sign in to comment.