[elbe-devel] [PATCH] elbepack: sign: use argparse for CLI parsing
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Tue Jul 30 09:47:42 CEST 2024
Provide more uniform error messages.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/commands/sign.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/elbepack/commands/sign.py b/elbepack/commands/sign.py
index d735b3cd4d05..47e89e560486 100644
--- a/elbepack/commands/sign.py
+++ b/elbepack/commands/sign.py
@@ -2,13 +2,16 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2014-2015, 2017 Linutronix GmbH
+import argparse
+
from elbepack.egpg import sign_file
def run_command(argv):
- if len(argv) != 2:
- print('Wrong number of arguments.')
- print('Please pass the name of the file to sign '
- 'and a valid gnupg fingerprint.')
- return
- sign_file(argv[0], argv[1])
+ parser = argparse.ArgumentParser(prog='elbe sign')
+ parser.add_argument('file', help='file to sign')
+ parser.add_argument('fingerprint', help='valid gnupg fingerprint')
+
+ args = parser.parse_args(argv)
+
+ sign_file(args.file, args.fingerprint)
---
base-commit: dcec7a10e0a4d63c7ee6c3d6077482ab98113211
change-id: 20240730-argparse-sign-23e0801872c5
Best regards,
--
Thomas Weißschuh <thomas.weissschuh at linutronix.de>
More information about the elbe-devel
mailing list