Skip to content

Commit

Permalink
[SCons] Remove old implementation of 'scons help'
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Nov 3, 2021
1 parent 2a7a061 commit 5b957e2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 92 deletions.
5 changes: 0 additions & 5 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -737,11 +737,6 @@ for option in opts.keys():
env[option] = modified

if "help" in COMMAND_LINE_TARGETS:

if ARGUMENTS.get("old") in ["True", "y", "yes"]:
help(env, opts)
sys.exit(0)

option = ARGUMENTS.get("option")
message = config.help(option, env=env)
logger.info(message, print_level=False)
Expand Down
88 changes: 1 addition & 87 deletions site_scons/buildutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
__all__ = ("Option", "PathOption", "BoolOption", "EnumOption", "Configuration",
"logger", "remove_directory", "remove_file", "test_results",
"add_RegressionTest", "get_command_output", "listify", "which",
"ConfigBuilder", "multi_glob", "get_spawn", "help", "quoted")
"ConfigBuilder", "multi_glob", "get_spawn", "quoted")

if TYPE_CHECKING:
from typing import Iterable, TypeVar
Expand Down Expand Up @@ -1049,92 +1049,6 @@ def which(program: str) -> bool:
return False


def help(env: "SCEnvironment", options: "SCVariables") -> None:
"""Print help about configuration options and exit.
Print a nicely formatted description of a SCons configuration
option, its permitted values, default value, and current value
if different from the default.
"""

message = [
textwrap.dedent(
"""
**************************************************
* Configuration options for building Cantera *
**************************************************
The following options can be passed to SCons to customize the Cantera
build process. They should be given in the form:
scons build option1=value1 option2=value2
Variables set in this way will be stored in the 'cantera.conf' file and reused
automatically on subsequent invocations of scons. Alternatively, the
configuration options can be entered directly into 'cantera.conf' before
running 'scons build'. The format of this file is:
option1 = 'value1'
option2 = 'value2'
**************************************************"""
)
]

option_wrapper = textwrap.TextWrapper(
initial_indent=4 * " ",
subsequent_indent=4 * " ",
width=72,
)
for opt in options.options:
# Extract the help description from the permitted values. Original format
# is in the format: "Help text (value1|value2)" for EnumVariable and
# BoolVariable types or "Help text" for other Variables
if opt.help.endswith(")"):
help, values = opt.help.rsplit("(", maxsplit=1)
values = values.rstrip(")").strip().replace("|", " | ")
if not values:
values = "string"
else:
help = opt.help
values = "string"

# First line: "* option-name: [ choice1 | choice2 ]"
lines = [f"* {opt.key}: [ {values} ]"]

# Help text, wrapped and indented 4 spaces
lines.extend(option_wrapper.wrap(re.sub(r"\s+", " ", help)))

# Fix the representation of Boolean options, which are stored as
# Python bool types
default = opt.default
if default is True:
default = "yes"
elif default is False:
default = "no"

lines.append(f" - default: {default!r}")

# Get the actual value in the current environment
if opt.key in env:
actual = env.subst(f"${opt.key!s}")
else:
actual = None

# Fix the representation of Boolean options to match the default values
if actual == "True":
actual = "yes"
elif actual == "False":
actual = "no"

# Print the value if it differs from the default
if actual != default:
lines.append(f" - actual: {actual!r}")
message.append("\n".join(lines))

logger.info("\n\n".join(message), print_level=False)


def listify(value: "Union[str, Iterable]") -> "List[str]":
"""
Convert an option specified as a string to a list, using spaces as
Expand Down

0 comments on commit 5b957e2

Please sign in to comment.