summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2021-01-28 20:06:24 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2021-03-03 19:50:44 +0100
commit8485985ed3287e6af928b7712c657a16bf2b4cb8 (patch)
tree37fb953eb24a982e3bff5e1b0ab9165d50d0b14d /utils
parentbb722a037351ea8d1017874195d1c10708a1a6fc (diff)
delete: Use GOptionContext to handle help
Diffstat (limited to 'utils')
-rw-r--r--utils/delete.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/utils/delete.c b/utils/delete.c
index 0f7e05d..427529e 100644
--- a/utils/delete.c
+++ b/utils/delete.c
@@ -155,16 +155,33 @@ process_devices (char **argv)
int
main (int argc, char **argv)
{
+ g_autoptr(GOptionContext) option_context = NULL;
+ g_autoptr(GError) local_error = NULL;
+
+ option_context = g_option_context_new ("Delete fingerprints");
+
setlocale (LC_ALL, "");
- create_manager ();
+ g_option_context_set_ignore_unknown_options (option_context, TRUE);
+ g_option_context_set_summary (option_context,
+ "<username> [usernames ...]");
+
+ if (!g_option_context_parse (option_context, &argc, &argv, &local_error))
+ {
+ g_print ("couldn't parse command-line options: %s\n", local_error->message);
+ return EXIT_FAILURE;
+ }
if (argc < 2)
{
- g_print ("Usage: %s <username> [usernames...]\n", argv[0]);
- return 1;
+ g_autofree char *usage = NULL;
+
+ usage = g_option_context_get_help (option_context, FALSE, NULL);
+ g_print ("%s", usage);
+ return EXIT_FAILURE;
}
+ create_manager ();
process_devices (argv);
return 0;