summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2019-12-14 18:39:03 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2019-12-14 19:02:48 +0100
commit7e6b9cf02b956d014303e0dd769488d179fea074 (patch)
tree03b6e62bdd9af48cb11adb090b641a2a2dfbd7da
parent2e08499ce38ca7bf2f368c4dc321ef8a6f287530 (diff)
listnewconfig: Add option for showing help texts
Show the help text for each new symbol if --show-help/-l is passed (-h might be confused for --help). Copycat of commit 5d8b42aa7ccb ("kconfig: Add option to get the full help text with listnewconfig") to the C tools, but with a slightly more compact output format (indented help text instead of separators).
-rwxr-xr-xlistnewconfig.py43
1 files changed, 36 insertions, 7 deletions
diff --git a/listnewconfig.py b/listnewconfig.py
index 435819b..bcb3f9c 100755
--- a/listnewconfig.py
+++ b/listnewconfig.py
@@ -4,22 +4,43 @@
# SPDX-License-Identifier: ISC
"""
-List all user-modifiable symbols that are not given a value in the configuration
-file. Usually, these are new symbols that have been added to the Kconfig files.
+Lists all user-modifiable symbols that are not given a value in the
+configuration file. Usually, these are new symbols that have been added to the
+Kconfig files.
The default configuration filename is '.config'. A different filename can be
passed in the KCONFIG_CONFIG environment variable.
"""
+from __future__ import print_function
+
+import argparse
import sys
-from kconfiglib import standard_kconfig, BOOL, TRISTATE, INT, HEX, STRING, \
- TRI_TO_STR
+from kconfiglib import Kconfig, BOOL, TRISTATE, INT, HEX, STRING, TRI_TO_STR
def main():
- kconf = standard_kconfig(__doc__)
+ parser = argparse.ArgumentParser(
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ description=__doc__)
+
+ parser.add_argument(
+ "--show-help", "-l",
+ action="store_true",
+ help="Show any help texts as well")
+
+ parser.add_argument(
+ "kconfig",
+ metavar="KCONFIG",
+ nargs="?",
+ default="Kconfig",
+ help="Top-level Kconfig file (default: Kconfig)")
+
+ args = parser.parse_args()
+
+ kconf = Kconfig(args.kconfig, suppress_traceback=True)
# Make it possible to filter this message out
- sys.stderr.write(kconf.load_config() + "\n")
+ print(kconf.load_config(), file=sys.stderr)
for sym in kconf.unique_defined_syms:
# Only show symbols that can be toggled. Choice symbols are a special
@@ -40,7 +61,15 @@ def main():
else:
s = sym.config_string
- sys.stdout.write(s)
+ print(s, end="")
+ if args.show_help:
+ for node in sym.nodes:
+ if node.help is not None:
+ # Indent by two spaces. textwrap.indent() is not
+ # available in Python 2 (it's 3.3+).
+ print("\n".join(" " + line
+ for line in node.help.split("\n")))
+ break
if __name__ == "__main__":