[elbe-devel] [PATCH] elbepack: remove_sign: use argparse for CLI parsing

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Jul 30 09:49:49 CEST 2024


Provide more uniform error messages.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/commands/remove_sign.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/elbepack/commands/remove_sign.py b/elbepack/commands/remove_sign.py
index 382e2c22c9c3..c582d351ea78 100644
--- a/elbepack/commands/remove_sign.py
+++ b/elbepack/commands/remove_sign.py
@@ -2,16 +2,18 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 # SPDX-FileCopyrightText: 2014, 2017 Linutronix GmbH
 
+import argparse
+
 from elbepack.egpg import unsign_file
 
 
 def run_command(argv):
-    if len(argv) != 1:
-        print('Wrong number of arguments.')
-        print('Please pass the name of the file to unsign.')
-        return
+    parser = argparse.ArgumentParser(prog='elbe remove_sign')
+    parser.add_argument('file', help='file to unsign')
+
+    args = parser.parse_args(argv)
 
-    fname = unsign_file(argv[0])
+    fname = unsign_file(args.file)
     if fname:
         print(f'unsigned file: {fname}')
     else:

---
base-commit: 202b042e0df5bbb744bc69ee9e08d09ca1025a61
change-id: 20240730-argparse-unsign-c140b510663f
prerequisite-change-id: 20240730-argparse-sign-23e0801872c5:v2

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh at linutronix.de>



More information about the elbe-devel mailing list