Skip to content

Commit

Permalink
options: Add -H/--help-regular option to list regular options.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpreiner committed Aug 8, 2023
1 parent e2dae2a commit 9d189c5
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/main/driver_unified.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ int runCvc5(int argc, char* argv[], std::unique_ptr<cvc5::Solver>& solver)
printUsage(progName, dopts.out());
exit(1);
}
else if (solver->getOptionInfo("help-regular").boolValue())
{
printUsage(progName, dopts.out(), true);
exit(1);
}
for (const auto& name : {"show-config",
"copyright",
"show-trace-tags",
Expand Down
4 changes: 3 additions & 1 deletion src/main/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ namespace cvc5::main {
* Print overall command-line option usage message to the given output stream
* with binary being the command to run cvc5.
*/
void printUsage(const std::string& binary, std::ostream& os);
void printUsage(const std::string& binary,
std::ostream& os,
bool printRegular = false);

/**
* Initialize the Options object options based on the given
Expand Down
21 changes: 17 additions & 4 deletions src/main/options_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,18 @@ R"FOOBAR(Additional cvc5 options:
${help_others}$
)FOOBAR";

static const std::string regularOptionsDescription =
R"FOOBAR(Regular cvc5 options:
${help_regular}$
)FOOBAR";

static const std::string optionsFootnote = "\n\
[*] Each of these options has a --no-OPTIONNAME variant, which reverses the\n\
sense of the option.\n\
";
// clang-format on

void printUsage(const std::string& binary, std::ostream& os)
void printUsage(const std::string& binary, std::ostream& os, bool printRegular)
{
os << "usage: " << binary << " [options] [input-file]" << std::endl
<< std::endl
Expand All @@ -75,9 +80,17 @@ void printUsage(const std::string& binary, std::ostream& os)
<< std::endl
<< "cvc5 options:" << std::endl
<< commonOptionsDescription << std::endl
<< std::endl
<< additionalOptionsDescription << std::endl
<< optionsFootnote << std::endl;
<< std::endl;

if (printRegular)
{
os << regularOptionsDescription << std::endl;
}
else
{
os << additionalOptionsDescription << std::endl;
}
os << optionsFootnote << std::endl;
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/options/main_options.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ name = "Driver"
alternate = false
help = "full command line reference"

[[option]]
name = "helpRegular"
category = "common"
long = "help-regular"
short = "H"
type = "bool"
default = "false"
alternate = false
help = "regular command line reference"

[[option]]
name = "showConfiguration"
category = "common"
Expand Down
8 changes: 6 additions & 2 deletions src/options/mkoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ def _cli_help_wrap(help_msg, opts):
def generate_cli_help(modules):
"""Generate the output for --help."""
common = []
regular = []
others = []
for module in modules:
if not module.options:
Expand All @@ -738,7 +739,9 @@ def generate_cli_help(modules):
common.extend(res)
else:
others.extend(res)
return '\n'.join(common), '\n'.join(others)
if option.category == 'regular':
regular.extend(res)
return '\n'.join(common), '\n'.join(others), '\n'.join(regular)


################################################################################
Expand Down Expand Up @@ -961,7 +964,7 @@ def codegen_module(module, dst_dir, tpls):
def codegen_all_modules(modules, src_dir, build_dir, dst_dir, tpls):
"""Generate code for all option modules."""
short, cmdline_opts, parseinternal = generate_parsing(modules)
help_common, help_others = generate_cli_help(modules)
help_common, help_others, help_regular = generate_cli_help(modules)

if os.path.isdir('{}/docs/'.format(build_dir)):
write_file('{}/docs/'.format(build_dir), 'options_generated.rst',
Expand Down Expand Up @@ -997,6 +1000,7 @@ def codegen_all_modules(modules, src_dir, build_dir, dst_dir, tpls):
# main/options.cpp
'help_common': help_common,
'help_others': help_others,
'help_regular': help_regular,
'cmdoptions_long': cmdline_opts,
'cmdoptions_short': short,
'parseinternal_impl': parseinternal,
Expand Down

0 comments on commit 9d189c5

Please sign in to comment.