3 from os
import get_terminal_size
4 from textwrap
import wrap
5 from mesonbuild
import coredata
6 from mesonbuild
import optinterpreter
8 (COLUMNS
, _
) = get_terminal_size()
10 def describe_option(option_name
: str, option_default_value
: str,
11 option_type
: str, option_message
: str) -> None:
12 print('name: ' + option_name
)
13 print('default: ' + option_default_value
)
14 print('type: ' + option_type
)
15 for line
in wrap(option_message
, width
=COLUMNS
- 9):
19 oi
= optinterpreter
.OptionInterpreter('')
20 oi
.process('meson_options.txt')
22 for (name
, value
) in oi
.options
.items():
23 if isinstance(value
, coredata
.UserStringOption
):
27 "You can type what you want, but make sure it makes sense")
28 elif isinstance(value
, coredata
.UserBooleanOption
):
30 'true' if value
.value
else 'false',
32 "You can set it to 'true' or 'false'")
33 elif isinstance(value
, coredata
.UserIntegerOption
):
37 "You can set it to any integer value between '{}' and '{}'".format(value
.min_value
, value
.max_value
))
38 elif isinstance(value
, coredata
.UserUmaskOption
):
42 "You can set it to 'preserve' or a value between '0000' and '0777'")
43 elif isinstance(value
, coredata
.UserComboOption
):
44 choices
= '[' + ', '.join(["'" + v
+ "'" for v
in value
.choices
]) + ']'
48 "You can set it to any one of those values: " + choices
)
49 elif isinstance(value
, coredata
.UserArrayOption
):
50 choices
= '[' + ', '.join(["'" + v
+ "'" for v
in value
.choices
]) + ']'
51 value
= '[' + ', '.join(["'" + v
+ "'" for v
in value
.value
]) + ']'
55 "You can set it to one or more of those values: " + choices
)
56 elif isinstance(value
, coredata
.UserFeatureOption
):
60 "You can set it to 'auto', 'enabled', or 'disabled'")
62 print(name
+ ' is an option of a type unknown to this script')