MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / build_settables

Method build_settables

cmd2/cmd2.py:1294–1352  ·  view source on GitHub ↗

Create the dictionary of user-settable parameters.

(self)

Source from the content-addressed store, hash-verified

1292 raise KeyError(name + " is not a settable parameter") from exc
1293
1294 def build_settables(self) -> None:
1295 """Create the dictionary of user-settable parameters."""
1296
1297 def get_allow_style_choices(_cli_self: Cmd) -> Choices:
1298 """Complete allow_style values."""
1299 styles = [val.name.lower() for val in ru.AllowStyle]
1300 return Choices.from_values(styles)
1301
1302 def allow_style_type(value: str) -> ru.AllowStyle:
1303 """Convert a string value into an ru.AllowStyle."""
1304 try:
1305 return ru.AllowStyle[value.upper()]
1306 except KeyError as ex:
1307 raise ValueError(
1308 f"must be {ru.AllowStyle.ALWAYS}, {ru.AllowStyle.NEVER}, or {ru.AllowStyle.TERMINAL} (case-insensitive)"
1309 ) from ex
1310
1311 settable_description = Text.assemble(
1312 "Allow styled text in output (Options: ",
1313 (str(ru.AllowStyle.ALWAYS), Style(bold=True)),
1314 ", ",
1315 (str(ru.AllowStyle.NEVER), Style(bold=True)),
1316 ", ",
1317 (str(ru.AllowStyle.TERMINAL), Style(bold=True)),
1318 ")",
1319 )
1320 self.add_settable(
1321 Settable(
1322 "allow_style",
1323 allow_style_type,
1324 ru.rich_text_to_string(settable_description),
1325 self,
1326 choices_provider=get_allow_style_choices,
1327 )
1328 )
1329 self.add_settable(Settable("debug", bool, "Show full traceback on exception", self))
1330 self.add_settable(Settable("echo", bool, "Echo command issued into output", self))
1331 self.add_settable(Settable("editor", str, "Program used by 'edit'", self))
1332 self.add_settable(Settable("feedback_to_output", bool, "Include nonessentials in '|' and '>' results", self))
1333 self.add_settable(
1334 Settable(
1335 "max_completion_table_items",
1336 int,
1337 "Max results allowed to display a table",
1338 self,
1339 )
1340 )
1341 self.add_settable(
1342 Settable(
1343 "max_column_completion_results",
1344 int,
1345 "Max results to display in a single column",
1346 self,
1347 )
1348 )
1349 self.add_settable(Settable("quiet", bool, "Don't print nonessential feedback", self))
1350 self.add_settable(Settable("scripts_add_to_history", bool, "Scripts and pyscripts add commands to history", self))
1351 self.add_settable(Settable("timing", bool, "Report execution times", self))

Callers 1

__init__Method · 0.95

Calls 2

add_settableMethod · 0.95
SettableClass · 0.85

Tested by

no test coverage detected