From eea471e3286b4b06246384d7e5c7ee96a9757531 Mon Sep 17 00:00:00 2001 From: Jameson Graef Rollins Date: Wed, 11 Apr 2012 00:22:01 +1700 Subject: [PATCH] Re: [PATCH v3 4/5] config: Add 'config list' command --- aa/42b175784a514f404f15eb243d16b15e8c17cc | 189 ++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 aa/42b175784a514f404f15eb243d16b15e8c17cc diff --git a/aa/42b175784a514f404f15eb243d16b15e8c17cc b/aa/42b175784a514f404f15eb243d16b15e8c17cc new file mode 100644 index 000000000..5da2c29fb --- /dev/null +++ b/aa/42b175784a514f404f15eb243d16b15e8c17cc @@ -0,0 +1,189 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 92984431FAF + for ; Tue, 10 Apr 2012 00:22:11 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.29 +X-Spam-Level: +X-Spam-Status: No, score=-2.29 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_MED=-2.3, T_MIME_NO_TEXT=0.01] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id zO5Msrzt36o3 for ; + Tue, 10 Apr 2012 00:22:11 -0700 (PDT) +Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu + [131.215.239.19]) + by olra.theworths.org (Postfix) with ESMTP id 0346F431FAE + for ; Tue, 10 Apr 2012 00:22:10 -0700 (PDT) +Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1]) + by fire-doxen-postvirus (Postfix) with ESMTP id 6A9EB2E50D7C; + Tue, 10 Apr 2012 00:22:10 -0700 (PDT) +X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new +Received: from finestructure.net (unknown [76.89.193.65]) + (Authenticated sender: jrollins) + by fire-doxen-submit (Postfix) with ESMTP id 7EA282E50D42; + Tue, 10 Apr 2012 00:22:07 -0700 (PDT) +Received: by finestructure.net (Postfix, from userid 1000) + id 1732D762; Tue, 10 Apr 2012 00:22:07 -0700 (PDT) +From: Jameson Graef Rollins +To: Peter Wang , notmuch@notmuchmail.org +Subject: Re: [PATCH v3 4/5] config: Add 'config list' command +In-Reply-To: <1333676886-9835-5-git-send-email-novalazy@gmail.com> +References: <1332282698-7951-1-git-send-email-novalazy@gmail.com> + <1333676886-9835-1-git-send-email-novalazy@gmail.com> + <1333676886-9835-5-git-send-email-novalazy@gmail.com> +User-Agent: Notmuch/0.12+108~g7bdb40c (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Tue, 10 Apr 2012 00:22:01 -0700 +Message-ID: <87r4vwhx0m.fsf@servo.finestructure.net> +MIME-Version: 1.0 +Content-Type: multipart/signed; boundary="=-=-="; + micalg=pgp-sha256; protocol="application/pgp-signature" +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 10 Apr 2012 07:22:11 -0000 + +--=-=-= +Content-Transfer-Encoding: quoted-printable + +On Thu, Apr 05 2012, Peter Wang wrote: +> Add a command to list all configuration items with their associated +> values. +> +> One use is as follows: a MUA may prefer to store data in a central +> notmuch configuration file so that the data is accessible across +> different machines, e.g. an addressbook. The list command helps +> to implement features such as tab completion on the keys. +> --- +> notmuch-config.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++= +++--- +> test/config | 1 - +> 2 files changed, 62 insertions(+), 5 deletions(-) +> +> diff --git a/notmuch-config.c b/notmuch-config.c +> index 85fc774..d5540ac 100644 +> --- a/notmuch-config.c +> +++ b/notmuch-config.c +> @@ -799,20 +799,78 @@ notmuch_config_command_set (void *ctx, char *item, = +int argc, char *argv[]) +> return ret; +> } +>=20=20 +> +static int +> +notmuch_config_command_list (void *ctx) +> +{ +> + notmuch_config_t *config; +> + char **groups; +> + size_t g, groups_length; +> + +> + config =3D notmuch_config_open (ctx, NULL, NULL); +> + if (config =3D=3D NULL) +> + return 1; +> + +> + groups =3D g_key_file_get_groups (config->key_file, &groups_length); +> + if (groups =3D=3D NULL) +> + return 1; +> + +> + for (g =3D 0; g < groups_length; g++) { +> + char **keys; +> + size_t k, keys_length; +> + +> + keys =3D g_key_file_get_keys (config->key_file, +> + groups[g], &keys_length, NULL); +> + if (keys =3D=3D NULL) +> + continue; +> + +> + for (k =3D 0; k < keys_length; k++) { +> + char *value; +> + +> + value =3D g_key_file_get_string (config->key_file, +> + groups[g], keys[k], NULL); +> + if (value !=3D NULL) { +> + printf ("%s.%s=3D%s\n", groups[g], keys[k], value); +> + free (value); +> + } +> + } +> + +> + g_strfreev (keys); +> + } +> + +> + g_strfreev (groups); +> + +> + notmuch_config_close (config); +> + +> + return 0; +> +} +> + +> int +> notmuch_config_command (void *ctx, int argc, char *argv[]) +> { +> argc--; argv++; /* skip subcommand argument */ +>=20=20 +> - if (argc < 2) { +> - fprintf (stderr, "Error: notmuch config requires at least two arguments= +.\n"); +> + if (argc < 1) { +> + fprintf (stderr, "Error: notmuch config requires at least one argument.= +\n"); +> return 1; +> } + +Hey, Peter. I would say everything up to here looks great. + +> - if (strcmp (argv[0], "get") =3D=3D 0) +> + if (strcmp (argv[0], "get") =3D=3D 0) { +> + if (argc < 2) { +> + fprintf (stderr, "Error: notmuch config get requires at least " +> + "two arguments.\n"); +> + return 1; +> + } +> return notmuch_config_command_get (ctx, argv[1]); +> - else if (strcmp (argv[0], "set") =3D=3D 0) +> + } else if (strcmp (argv[0], "set") =3D=3D 0) { +> + if (argc < 2) { +> + fprintf (stderr, "Error: notmuch config set requires at least " +> + "two arguments.\n"); +> + return 1; +> + } +> return notmuch_config_command_set (ctx, argv[1], argc - 2, argv + 2); + +But then these changes look unrelated to me. They do look good +intentioned, though. It's probably best to submit these changes in a +separate unrelated patch. + +jamie. + +--=-=-= +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.12 (GNU/Linux) + +iQIcBAEBCAAGBQJPg9+aAAoJEO00zqvie6q8svMQAIR79rchJLmp9H04JOjdn8pi +GNMTmW3IXH9mTe4H86vvGbeSHZh2ERp3NR8nFDkjmLD7JMMPagvoGLXA8HLVwlDA +3Fmar/lqIjvbknUjch5Ho/a6hykuzXScO09FPw5Y2B/vr6mWrhcaqUeZ/HHJ5eUc +SFhFT3pN08J54cbOFEUmMEZ5MtVd+JgsweLaKf4rNyXcrYv/0x+8gZbh2kZqVMYn +UAe4ZvvQTmKyDN60dCeutATkhE8BVu6wtDU5dOov11cho9lHj5Oz+VKeTNx2ahok +Nsd5vOHim3uB08L7Y1i8KYfy+wU8a7UDQzoO0LdxkEKpooICLsX3Jk6eVtRUhdg1 +64EHzKd55vxMF7psJvw2hoacfVmMHUinMdPjutT0z4RiLhKL1PDyPEv3eA4GBfPN +RkNBXYz9HcP/4LGHsVAQ08xmIeu9+hQpxR0qszJ4m89lBVoQoKMJtJ3ttq5V/mQo +wPX5zGOCWCY4EDzBm0s+OArO88a1bUBbquegN7z0asoucS06Xd3cb4LhmM4TywDV +Meh9k2p337IPpRB2p+qV9TWuud+f9597Z24cAyT+gn9JbKAoE5WVdyzzcBRPWaxU +cmXGwsj8GDvkJ/93Q7S1TQXzPTRrXhY9IislBQUkAKAvoprok6Jc03ZSpSHuw2mC +IfYXph/namcKZi+ETteA +=ZGEU +-----END PGP SIGNATURE----- +--=-=-=-- -- 2.26.2