aboutsummaryrefslogtreecommitdiff
path: root/cast/standalone_receiver/main.cc
diff options
context:
space:
mode:
authorYuri Wiitala <miu@chromium.org>2020-10-26 12:30:13 -0700
committerCommit Bot <commit-bot@chromium.org>2020-10-26 20:44:44 +0000
commit2837c9f0c416803cbab994f1fe10296d2a132971 (patch)
treedae3d9a0167f1bc6a56ee65be4f329ce086b73ed /cast/standalone_receiver/main.cc
parent83e50af3e0bd628e7307e67e0ae1c6a611b8d7bb (diff)
downloadopenscreen-2837c9f0c416803cbab994f1fe10296d2a132971.tar.gz
Add StringPrintf() wrapper utility.
Adds an efficient wrapper around std::snprintf() that returns the formatted result in a std::string. Background: The issue of either 1) wanting to use absl::StrFormat() without bloating our binary sizes, or 2) manually writing char[] buffer code around std::snprintf() has come up several times over the past year or so. So, this new utility is about reducing friction and improving future developer velocity. Change-Id: Ie898f91575852b06d59844dd564a0da03df1f7ed Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2487768 Commit-Queue: Yuri Wiitala <miu@chromium.org> Reviewed-by: Yuri Wiitala <miu@chromium.org> Reviewed-by: Brandon Tolsch <btolsch@chromium.org>
Diffstat (limited to 'cast/standalone_receiver/main.cc')
-rw-r--r--cast/standalone_receiver/main.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/cast/standalone_receiver/main.cc b/cast/standalone_receiver/main.cc
index 0c9d3c1b..4e8c321c 100644
--- a/cast/standalone_receiver/main.cc
+++ b/cast/standalone_receiver/main.cc
@@ -116,16 +116,15 @@ std::unique_ptr<CastAgent> StartCastAgent(TaskRunnerImpl* task_runner,
}
void LogUsage(const char* argv0) {
- std::cerr << R"(
-usage: )" << argv0
- << R"( <options> <interface>
+ constexpr char kTemplate[] = R"(
+usage: %s <options> <interface>
-options:
interface
Specifies the network interface to bind to. The interface is
looked up from the system interface registry.
Mandatory, as it must be known for publishing discovery.
+options:
-p, --private-key=path-to-key: Path to OpenSSL-generated private key to be
used for TLS authentication. If a private key is not
provided, a randomly generated one will be used for this
@@ -153,7 +152,9 @@ options:
-v, --verbose: Enable verbose logging.
-h, --help: Show this help message.
- )";
+)";
+
+ std::cerr << StringPrintf(kTemplate, argv0);
}
InterfaceInfo GetInterfaceInfoFromName(const char* name) {