[d8] move 'Synopsis' from flags.cc into d8.cc

This commit moves the d8 Synopsis/Usage string from flags.cc into d8.cc.

The motivation for this is that Commit
c8679386bd ("[snapshot] enable mksnapshot
usage to be displayed") enabled a usage string to be passed into

means mksnapshot --help will first print it's own usage string followed
by d8's.

FlagList: :SetFlagsFromCommandLine and be printed, but
FlagList: :PrintHelp currently still prints the Synopsis for d8 which
Change-Id: I9c79b2cdc5570106e12096c0c53e640cf80742e9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2299365
Reviewed-by: Dan Elphick <delphick@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68912}
This commit is contained in:
Daniel Bevenius 2020-07-17 13:09:16 +02:00 committed by Commit Bot
parent c3c4830da6
commit b7430e99c3
2 changed files with 14 additions and 11 deletions

View File

@ -38,6 +38,7 @@
#include "src/deoptimizer/deoptimizer.h"
#include "src/diagnostics/basic-block-profiler.h"
#include "src/execution/vm-state-inl.h"
#include "src/flags/flags.h"
#include "src/handles/maybe-handles.h"
#include "src/init/v8.h"
#include "src/interpreter/interpreter.h"
@ -3383,7 +3384,16 @@ bool Shell::SetOptions(int argc, char* argv[]) {
}
}
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
const char* usage =
"Synopsis:\n"
" shell [options] [--shell] [<file>...]\n"
" d8 [options] [-e <string>] [--shell] [[--module] <file>...]\n\n"
" -e execute a string in V8\n"
" --shell run an interactive JavaScript shell\n"
" --module execute a file as a JavaScript module\n\n";
using HelpOptions = i::FlagList::HelpOptions;
i::FlagList::SetFlagsFromCommandLine(&argc, argv, true,
HelpOptions(HelpOptions::kExit, usage));
options.mock_arraybuffer_allocator = i::FLAG_mock_arraybuffer_allocator;
options.mock_arraybuffer_allocator_limit =
i::FLAG_mock_arraybuffer_allocator_limit;

View File

@ -568,21 +568,14 @@ void FlagList::PrintHelp() {
CpuFeatures::PrintFeatures();
StdoutStream os;
os << "Synopsis:\n"
" shell [options] [--shell] [<file>...]\n"
" d8 [options] [-e <string>] [--shell] [[--module] <file>...]\n\n"
" -e execute a string in V8\n"
" --shell run an interactive JavaScript shell\n"
" --module execute a file as a JavaScript module\n\n"
"Note: the --module option is implicitly enabled for *.mjs files.\n\n"
"The following syntax for options is accepted (both '-' and '--' are "
os << "The following syntax for options is accepted (both '-' and '--' are "
"ok):\n"
" --flag (bool flags only)\n"
" --no-flag (bool flags only)\n"
" --flag=value (non-bool flags only, no spaces around '=')\n"
" --flag value (non-bool flags only)\n"
" -- (captures all remaining args in JavaScript)\n\n"
"Options:\n";
" -- (captures all remaining args in JavaScript)\n\n";
os << "Options:\n";
for (const Flag& f : flags) {
os << " --";