From 084284a9e03027e3d5e542db0703cad706a5e6c5 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Mon, 11 Feb 2008 17:00:17 +0000 Subject: [PATCH] Add --uri support to eds-get-vcard --- tools/eds-get-vcard.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/eds-get-vcard.c b/tools/eds-get-vcard.c index 77b9928..8d1617f 100644 --- a/tools/eds-get-vcard.c +++ b/tools/eds-get-vcard.c @@ -1,21 +1,41 @@ #include #include "util.h" +static char *uri = NULL; + +static const GOptionEntry options[] = { + { "uri", 'u', 0, G_OPTION_ARG_STRING, &uri, "URI of book to open (default: system addressbook)." }, + { NULL } +}; + + int main (int argc, char **argv) { GError *error = NULL; + GOptionContext *context; EBook *book; EContact *contact = NULL; g_type_init (); + context = g_option_context_new (" - get vCard"); + g_option_context_add_main_entries (context, options, NULL); + if (!g_option_context_parse (context, &argc, &argv, &error)) { + g_error ("Cannot parse arguments: %s", error->message); + } + if (argc != 2) { - g_print ("Usage: eds-get-vcard "); + g_print ("Usage: eds-get-vcard \n"); return 1; } - book = e_book_new_system_addressbook (&error); + if (uri) { + book = e_book_new_from_uri (uri, &error); + g_free (uri); + } else { + book = e_book_new_system_addressbook (&error); + } if (!book) die ("Cannot get book", error);