CommandLineInterface: Group and reorder command-line options

This commit is contained in:
Kamil Śliwak 2020-05-29 22:28:07 +02:00
parent 5333e35cd7
commit 7bd7ff3d7d

View File

@ -738,7 +738,7 @@ remap paths using the context:prefix=path syntax.
Example: Example:
solc --)" + g_argBinary + R"( -o /tmp/solcoutput dapp-bin=/usr/local/lib/dapp-bin contract.sol solc --)" + g_argBinary + R"( -o /tmp/solcoutput dapp-bin=/usr/local/lib/dapp-bin contract.sol
Allowed options)").c_str(), General Information)").c_str(),
po::options_description::m_default_line_length, po::options_description::m_default_line_length,
po::options_description::m_default_line_length - 23 po::options_description::m_default_line_length - 23
); );
@ -746,28 +746,33 @@ Allowed options)").c_str(),
(g_argHelp.c_str(), "Show help message and exit.") (g_argHelp.c_str(), "Show help message and exit.")
(g_argVersion.c_str(), "Show version and exit.") (g_argVersion.c_str(), "Show version and exit.")
(g_strLicense.c_str(), "Show licensing information and exit.") (g_strLicense.c_str(), "Show licensing information and exit.")
;
po::options_description inputOptions("Input Options");
inputOptions.add_options()
( (
g_strEVMVersion.c_str(), g_argBasePath.c_str(),
po::value<string>()->value_name("version"), po::value<string>()->value_name("path"),
"Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon, " "Use the given path as the root of the source tree instead of the root of the filesystem."
"byzantium, constantinople, petersburg, istanbul (default) or berlin."
) )
( (
g_argPrettyJson.c_str(), g_argAllowPaths.c_str(),
"Output JSON in pretty format. Currently it only works with the combined JSON output." po::value<string>()->value_name("path(s)"),
"Allow a given path for imports. A list of paths can be supplied by separating them with a comma."
) )
( (
g_argLibraries.c_str(), g_argIgnoreMissingFiles.c_str(),
po::value<vector<string>>()->value_name("libs"), "Ignore missing files."
"Direct string or file containing library addresses. Syntax: "
"<libraryName>:<address> [, or whitespace] ...\n"
"Address is interpreted as a hex string optionally prefixed by 0x."
) )
( (
g_strRevertStrings.c_str(), g_argErrorRecovery.c_str(),
po::value<string>()->value_name(boost::join(g_revertStringsArgs, ",")), "Enables additional parser error recovery."
"Strip revert (and require) reason strings or add additional debugging information."
) )
;
desc.add(inputOptions);
po::options_description outputOptions("Output Options");
outputOptions.add_options()
( (
(g_argOutputDir + ",o").c_str(), (g_argOutputDir + ",o").c_str(),
po::value<string>()->value_name("path"), po::value<string>()->value_name("path"),
@ -778,24 +783,30 @@ Allowed options)").c_str(),
"Overwrite existing files (used together with -o)." "Overwrite existing files (used together with -o)."
) )
( (
g_argCombinedJson.c_str(), g_strEVMVersion.c_str(),
po::value<string>()->value_name(boost::join(g_combinedJsonArgs, ",")), po::value<string>()->value_name("version"),
"Output a single json document containing the specified information." "Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon, "
"byzantium, constantinople, petersburg, istanbul (default) or berlin."
) )
( (
g_argGas.c_str(), g_strRevertStrings.c_str(),
"Print an estimate of the maximal gas usage for each function." po::value<string>()->value_name(boost::join(g_revertStringsArgs, ",")),
"Strip revert (and require) reason strings or add additional debugging information."
) )
;
desc.add(outputOptions);
po::options_description alternativeInputModes("Alternative Input Modes");
alternativeInputModes.add_options()
( (
g_argStandardJSON.c_str(), g_argStandardJSON.c_str(),
"Switch to Standard JSON input / output mode, ignoring all options. " "Switch to Standard JSON input / output mode, ignoring all options. "
"It reads from standard input, if no input file was given, otherwise it reads from the provided input file. The result will be written to standard output." "It reads from standard input, if no input file was given, otherwise it reads from the provided input file. The result will be written to standard output."
) )
( (
g_argImportAst.c_str(), g_argLink.c_str(),
("Import ASTs to be compiled, assumes input holds the AST in compact JSON format. " ("Switch to linker mode, ignoring all options apart from --" + g_argLibraries + " "
"Supported Inputs is the output of the --" + g_argStandardJSON + " or the one produced by " "and modify binaries in place.").c_str()
"--" + g_argCombinedJson + " " + g_strAst + "," + g_strCompactJSON).c_str()
) )
( (
g_argAssemble.c_str(), g_argAssemble.c_str(),
@ -816,38 +827,46 @@ Allowed options)").c_str(),
"and assumes input is strict assembly.").c_str() "and assumes input is strict assembly.").c_str()
) )
( (
g_strYulDialect.c_str(), g_argImportAst.c_str(),
po::value<string>()->value_name(boost::join(g_yulDialectArgs, ",")), ("Import ASTs to be compiled, assumes input holds the AST in compact JSON format. "
"Input dialect to use in assembly or yul mode." "Supported Inputs is the output of the --" + g_argStandardJSON + " or the one produced by "
"--" + g_argCombinedJson + " " + g_strAst + "," + g_strCompactJSON).c_str()
) )
;
desc.add(alternativeInputModes);
po::options_description assemblyModeOptions("Assembly Mode Options");
assemblyModeOptions.add_options()
( (
g_argMachine.c_str(), g_argMachine.c_str(),
po::value<string>()->value_name(boost::join(g_machineArgs, ",")), po::value<string>()->value_name(boost::join(g_machineArgs, ",")),
"Target machine in assembly or Yul mode." "Target machine in assembly or Yul mode."
) )
( (
g_argLink.c_str(), g_strYulDialect.c_str(),
("Switch to linker mode, ignoring all options apart from --" + g_argLibraries + " " po::value<string>()->value_name(boost::join(g_yulDialectArgs, ",")),
"and modify binaries in place.").c_str() "Input dialect to use in assembly or yul mode."
) )
;
desc.add(assemblyModeOptions);
po::options_description linkerModeOptions("Linker Mode Options");
linkerModeOptions.add_options()
( (
g_argMetadataHash.c_str(), g_argLibraries.c_str(),
po::value<string>()->value_name(boost::join(g_metadataHashArgs, ",")), po::value<vector<string>>()->value_name("libs"),
"Choose hash method for the bytecode metadata or disable it." "Direct string or file containing library addresses. Syntax: "
"<libraryName>:<address> [, or whitespace] ...\n"
"Address is interpreted as a hex string optionally prefixed by 0x."
) )
;
desc.add(linkerModeOptions);
po::options_description outputFormatting("Output Formatting");
outputFormatting.add_options()
( (
g_argMetadataLiteral.c_str(), g_argPrettyJson.c_str(),
"Store referenced sources as literal data in the metadata output." "Output JSON in pretty format. Currently it only works with the combined JSON output."
)
(
g_argAllowPaths.c_str(),
po::value<string>()->value_name("path(s)"),
"Allow a given path for imports. A list of paths can be supplied by separating them with a comma."
)
(
g_argBasePath.c_str(),
po::value<string>()->value_name("path"),
"Use the given path as the root of the source tree instead of the root of the filesystem."
) )
( (
g_argColor.c_str(), g_argColor.c_str(),
@ -861,40 +880,8 @@ Allowed options)").c_str(),
g_argOldReporter.c_str(), g_argOldReporter.c_str(),
"Enables old diagnostics reporter." "Enables old diagnostics reporter."
) )
(
g_argErrorRecovery.c_str(),
"Enables additional parser error recovery."
)
(
g_argIgnoreMissingFiles.c_str(),
"Ignore missing files."
)
; ;
po::options_description optimizerOptions("Optimizer options"); desc.add(outputFormatting);
optimizerOptions.add_options()
(g_argOptimize.c_str(), "Enable bytecode optimizer.")
(
g_argOptimizeRuns.c_str(),
po::value<unsigned>()->value_name("n")->default_value(200),
"Set for how many contract runs to optimize. "
"Lower values will optimize more for initial deployment cost, higher values will optimize more for high-frequency usage."
)
(
g_strOptimizeYul.c_str(),
("Legacy option, ignored. Use the general --" + g_argOptimize + " to enable Yul optimizer.").c_str()
)
(
g_strNoOptimizeYul.c_str(),
"Disable Yul optimizer in Solidity."
)
(
g_strYulOptimizations.c_str(),
po::value<string>()->value_name("steps"),
"Forces yul optimizer to use the specified sequence of optimization steps instead of the built-in one."
)
;
desc.add(optimizerOptions);
po::options_description outputComponents("Output Components"); po::options_description outputComponents("Output Components");
outputComponents.add_options() outputComponents.add_options()
@ -917,6 +904,62 @@ Allowed options)").c_str(),
; ;
desc.add(outputComponents); desc.add(outputComponents);
po::options_description extraOutput("Extra Output");
extraOutput.add_options()
(
g_argGas.c_str(),
"Print an estimate of the maximal gas usage for each function."
)
(
g_argCombinedJson.c_str(),
po::value<string>()->value_name(boost::join(g_combinedJsonArgs, ",")),
"Output a single json document containing the specified information."
)
;
desc.add(extraOutput);
po::options_description metadataOptions("Metadata Options");
metadataOptions.add_options()
(
g_argMetadataHash.c_str(),
po::value<string>()->value_name(boost::join(g_metadataHashArgs, ",")),
"Choose hash method for the bytecode metadata or disable it."
)
(
g_argMetadataLiteral.c_str(),
"Store referenced sources as literal data in the metadata output."
)
;
desc.add(metadataOptions);
po::options_description optimizerOptions("Optimizer Options");
optimizerOptions.add_options()
(
g_argOptimize.c_str(),
"Enable bytecode optimizer."
)
(
g_argOptimizeRuns.c_str(),
po::value<unsigned>()->value_name("n")->default_value(200),
"Set for how many contract runs to optimize. "
"Lower values will optimize more for initial deployment cost, higher values will optimize more for high-frequency usage."
)
(
g_strOptimizeYul.c_str(),
("Legacy option, ignored. Use the general --" + g_argOptimize + " to enable Yul optimizer.").c_str()
)
(
g_strNoOptimizeYul.c_str(),
"Disable Yul optimizer in Solidity."
)
(
g_strYulOptimizations.c_str(),
po::value<string>()->value_name("steps"),
"Forces yul optimizer to use the specified sequence of optimization steps instead of the built-in one."
)
;
desc.add(optimizerOptions);
po::options_description allOptions = desc; po::options_description allOptions = desc;
allOptions.add_options()(g_argInputFile.c_str(), po::value<vector<string>>(), "input file"); allOptions.add_options()(g_argInputFile.c_str(), po::value<vector<string>>(), "input file");