From ec031fb92728027ffcd6b64283d4118e739d40c2 Mon Sep 17 00:00:00 2001 From: Andrea Righi Date: Mon, 5 Dec 2022 07:44:25 +0100 Subject: [PATCH] annotations: accept config options with or without CONFIG_ prefix Allow to specify config options with or without CONFIG_ prefix in the commands --write and --note, to be consistent with --query that already accepts both formats. Reported-by: Masahiro Yamada Signed-off-by: Andrea Righi --- annotations | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/annotations b/annotations index 37f7987..ff6b54e 100755 --- a/annotations +++ b/annotations @@ -78,37 +78,45 @@ def do_query(args): def do_note(args): if args.config is None: arg_fail('error: --note requires --config') + if args.config.startswith('CONFIG_'): + config = args.config + else: + config = 'CONFIG_' + args.config # Set the note in annotations a = Annotation(args.file) - a.set(args.config, note=args.note) + a.set(config, note=args.note) # Save back to annotations a.save(args.file) # Query and print back the value a = Annotation(args.file) - res = a.search_config(config=args.config) - print_result(args.config, res) + res = a.search_config(config=config) + print_result(config, res) def do_write(args): if args.config is None: arg_fail('error: --write requires --config') + if args.config.startswith('CONFIG_'): + config = args.config + else: + config = 'CONFIG_' + args.config # Set the value in annotations ('null' means remove) a = Annotation(args.file) if args.value == 'null': - a.remove(args.config, arch=args.arch, flavour=args.flavour) + a.remove(config, arch=args.arch, flavour=args.flavour) else: - a.set(args.config, arch=args.arch, flavour=args.flavour, value=args.value, note=args.note) + a.set(config, arch=args.arch, flavour=args.flavour, value=args.value, note=args.note) # Save back to annotations a.save(args.file) # Query and print back the value a = Annotation(args.file) - res = a.search_config(config=args.config) - print_result(args.config, res) + res = a.search_config(config=config) + print_result(config, res) def do_export(args): if args.arch is None: -- 2.31.1