Skip to content

Commit

Permalink
#576 add usage synopsis to VT help
Browse files Browse the repository at this point in the history
- Added description and synopsis covering argument modes,
  switching between modes, and usages of such..

- Also unifies naming including that in banner messages.
  - "VT args" - used by VT configuration; --vt_*
  - "Application args" - supplied down-stream as argv
  - "MPI args" - used for MPI Init
  • Loading branch information
pnstickne authored and lifflander committed Jun 11, 2020
1 parent 1d6f4fc commit 57d9886
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
32 changes: 31 additions & 1 deletion src/vt/configs/arguments/args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,34 @@ void addSchedulerArgs(CLI::App& app) {
kca->group(schedulerGroup);
}

class VtFormatter : public CLI::Formatter {
public:
std::string make_usage(const CLI::App *, std::string name) const override {
std::stringstream u;
u << "\n"
"Usage:"
"\n"
"[APP-ARGS..] [VT-ARGS] [--vt_mpi_args MPI-ARGS..] [-- APP-ARGS..]\n"
"\n"
"Arguments up until the first '--vt_*' are treated as application arguments.\n"
"\n"
"After the first '--vt_*', additional arguments are treated as VT arguments\n"
"unless '--vt_mpi_args' or '--' are used to switch the argument mode.\n"
"The '--vt_args' flag can be used to switch back into VT argument mode.\n"
"Modes can be switched indefinitely.\n"
"\n"
"Application pass-through arguments are supplied to the host program\n"
"for further processing and are not used by VT for any configuration.\n"
"MPI (and only MPI) arguments are given directly to MPI_Init.\n"
"\n"
"It is an error if an unexpected argument is encountered in VT argument mode.\n"
"The currently recognized VT arguments are listed below; availability varies\n"
"based on build and compilation settings.\n"
<< "\n";
return u.str();
}
};

std::tuple<int, std::string> parseArguments(CLI::App& app, int& argc, char**& argv);

/*static*/ std::tuple<int, std::string> ArgParse::parse(int& argc, char**& argv) {
Expand All @@ -566,7 +594,9 @@ std::tuple<int, std::string> parseArguments(CLI::App& app, int& argc, char**& ar
return std::make_tuple(-1, std::string{});
}

CLI::App app{"vt"};
CLI::App app{"vt (Virtual Transport)"};

app.formatter(std::make_shared<VtFormatter>());

app.set_help_flag("--vt_help", "Display help");

Expand Down
2 changes: 1 addition & 1 deletion src/vt/runtime/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Runtime::Runtime(
// exit code of 0 -> 'help'
std::ostream& out = exit_code == 0 ? std::cout : std::cerr;

out << "--- VT INITIALIZATION ABORT ---" << "\n"
out << "--- VT INITIALIZATION ABORT ---" << "\n\n"
<< msg << "\n"
<< "--- VT INITIALIZATION ABORT ---" << "\n"
<< std::flush;
Expand Down
2 changes: 1 addition & 1 deletion src/vt/runtime/runtime_banner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ void Runtime::printStartupBanner() {
}
if (not passthru_args.empty()) {
auto f11 = fmt::format(
"Pass-through args: [{}]\n",
"Application args: [{}]\n",
arg_str(passthru_args)
);
fmt::print("{}\t{}{}", vt_pre, f11, reset);
Expand Down

0 comments on commit 57d9886

Please sign in to comment.