/*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// Guess the program name as basename(executable)
std::string guessProgramName() {
try {
- return fs::executable_path().filename().native();
+ return fs::executable_path().filename().string();
} catch (const std::exception&) {
return "UNKNOWN";
}
ProgramExit::ProgramExit(int status, const std::string& msg)
: std::runtime_error(msg),
status_(status) {
- CHECK_NE(status, 0);
+ // Message is only allowed for non-zero exit status
+ CHECK(status_ != 0 || msg.empty());
}
NestedCommandLineApp::NestedCommandLineApp(
}
void NestedCommandLineApp::displayHelp(
- const po::variables_map& globalOptions,
+ const po::variables_map& /* globalOptions */,
const std::vector<std::string>& args) {
if (args.empty()) {
// General help
// Help for a given command
auto& p = findCommand(args.front());
if (p.first != args.front()) {
- printf("`%1$s' is an alias for `%2$s'; showing help for `%2$s'\n",
- args.front().c_str(), p.first.c_str());
+ printf("`%s' is an alias for `%s'; showing help for `%s'\n",
+ args.front().c_str(), p.first.c_str(), p.first.c_str());
}
auto& info = p.second;
info.argStr.empty() ? "" : " ",
info.argStr.c_str());
+ printf("%s\n", info.fullHelp.c_str());
+
std::cout << globalOptions_;
if (!info.options.options().empty()) {
printf("\n");
std::cout << info.options;
}
-
- printf("\n%s\n", info.fullHelp.c_str());
}
}
int NestedCommandLineApp::run(int argc, const char* const argv[]) {
if (programName_.empty()) {
- programName_ = fs::path(argv[0]).filename().native();
+ programName_ = fs::path(argv[0]).filename().string();
}
return run(std::vector<std::string>(argv + 1, argv + argc));
}