From nobody Sun Feb 8 12:18:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1563897832; cv=none; d=zoho.com; s=zohoarc; b=l5UQlZev1gTCoQJO7cdqkDf3jaOErpEie5XRMg+4lDeY7QUjonoPenQLDbL8+3/FRmKUnabaHe+wX+jPice6TEfEY6jXdPCK7GnkhhL3ayM06Kmobu46beSzZpqZq+LSvvKysJEYFKEPET4JHSKe+rGUEE73Jwkt77vQRshF0Ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563897832; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=g/4oZHoILUjSOKL1jtawjSEBLwMzdBjCrOFyiK9bKsI=; b=mqheNWfP52seTXrLiFAHdoasKY2Vwuje4gesZr9Y7uQokayTy4FmDNEXI9WDmyZw716MXn/fV+w73Tr17/qZ18bltA5ajq1FAaKsn7U/L2nVkIuqbZaciqlJSaaJmN9gXmN0DK/52z0ZWp8Mw+sNAaW9CydHI2btTnyUNJXTYtg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1563897832411234.44951710259033; Tue, 23 Jul 2019 09:03:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE027A3B6F; Tue, 23 Jul 2019 16:03:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4CCD19D7B; Tue, 23 Jul 2019 16:03:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 658841800209; Tue, 23 Jul 2019 16:03:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6NG3nHG024566 for ; Tue, 23 Jul 2019 12:03:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7F70E5C25A; Tue, 23 Jul 2019 16:03:49 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.112.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7AC575C54A; Tue, 23 Jul 2019 16:03:41 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 23 Jul 2019 17:02:44 +0100 Message-Id: <20190723160319.18153-7-berrange@redhat.com> In-Reply-To: <20190723160319.18153-1-berrange@redhat.com> References: <20190723160319.18153-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/41] remote: stop trying to print help as giant blocks of text X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 23 Jul 2019 16:03:51 +0000 (UTC) The remote daemon tries to print out its help text in a couple of giant blocks of text. This has already lead to duplication of the text for the privileged vs unprivileged execution mode. With the introduction of more daemons, this text is going to be duplicated many more times with small variations. This is very unfriendly to translators as they have to translate approximately the same text many times with small tweaks. Splitting the text up into individual strings to print means that each piece will only need translating once. It also gets rid of all the layout information from the translated strings, so avoids the problem of translators breaking formatting by mistake. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/remote/remote_daemon.c | 126 ++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 64 deletions(-) diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index d887b7abfb..49ac3f0ae5 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -863,71 +863,69 @@ daemonSetupHostUUID(const struct daemonConfig *config) static void daemonUsage(const char *argv0, bool privileged) { - fprintf(stderr, - _("\n" - "Usage:\n" - " %s [options]\n" - "\n" - "Options:\n" - " -h | --help Display program help:\n" - " -v | --verbose Verbose messages.\n" - " -d | --daemon Run as a daemon & write PID file.\= n" - " -l | --listen Listen for TCP/IP connections.\n" - " -t | --timeout Exit after timeout period.\n" - " -f | --config Configuration file.\n" - " -V | --version Display version information.\n" - " -p | --pid-file Change name of PID file.\n" - "\n" - "libvirt management daemon:\n"), - argv0); + size_t i; + struct virOptionHelp { + const char *opts; + const char *help; + } opthelp[] =3D { + { "-h | --help", N_("Display program help") }, + { "-v | --verbose", N_("Verbose messages") }, + { "-d | --daemon", N_("Run as a daemon & write PID file") }, + { "-l | --listen", N_("Listen for TCP/IP connections") }, + { "-t | --timeout ", N_("Exit after timeout period") }, + { "-f | --config ", N_("Configuration file") }, + { "-V | --version", N_("Display version information") }, + { "-p | --pid-file ", N_("Change name of PID file") }, + }; =20 - if (privileged) { - fprintf(stderr, - _("\n" - " Default paths:\n" - "\n" - " Configuration file (unless overridden by -f):\n" - " %s\n" - "\n" - " Sockets:\n" - " %s\n" - " %s\n" - "\n" - " TLS:\n" - " CA certificate: %s\n" - " Server certificate: %s\n" - " Server private key: %s\n" - "\n" - " PID file (unless overridden by -p):\n" - " %s/run/libvirtd.pid\n" - "\n"), - LIBVIRTD_CONFIGURATION_FILE, - LIBVIRTD_PRIV_UNIX_SOCKET, - LIBVIRTD_PRIV_UNIX_SOCKET_RO, - LIBVIRT_CACERT, - LIBVIRT_SERVERCERT, - LIBVIRT_SERVERKEY, - LOCALSTATEDIR); - } else { - fprintf(stderr, "%s", - _("\n" - " Default paths:\n" - "\n" - " Configuration file (unless overridden by -f):\n" - " $XDG_CONFIG_HOME/libvirt/libvirtd.conf\n" - "\n" - " Sockets:\n" - " $XDG_RUNTIME_DIR/libvirt/libvirt-sock\n" - "\n" - " TLS:\n" - " CA certificate: $HOME/.pki/libvirt/cacert.pem= \n" - " Server certificate: $HOME/.pki/libvirt/servercert= .pem\n" - " Server private key: $HOME/.pki/libvirt/serverkey.= pem\n" - "\n" - " PID file:\n" - " $XDG_RUNTIME_DIR/libvirt/libvirtd.pid\n" - "\n")); - } + fprintf(stderr, "\n"); + fprintf(stderr, "%s:\n", _("Usage")); + fprintf(stderr, " %s [%s]\n", argv0, _("options")); + fprintf(stderr, "\n"); + + fprintf(stderr, "%s:\n", _("Options")); + for (i =3D 0; i < ARRAY_CARDINALITY(opthelp); i++) + fprintf(stderr, " %-22s %s\n", opthelp[i].opts, N_(opthelp[i].hel= p)); + fprintf(stderr, "\n"); + + fprintf(stderr, "%s:\n", _("libvirt management daemon")); + + fprintf(stderr, "\n"); + fprintf(stderr, " %s:\n", _("Default paths")); + fprintf(stderr, "\n"); + + fprintf(stderr, " %s:\n", _("Configuration file (unless overridden = by -f)")); + fprintf(stderr, " %s/libvirt/libvirtd.conf\n", + privileged ? SYSCONFDIR : "$XDG_CONFIG_HOME"); + fprintf(stderr, "\n"); + + fprintf(stderr, " %s:\n", _("Sockets")); + fprintf(stderr, " %s\n", + privileged ? LOCALSTATEDIR "/run/libvirt/libvirt-sock" : + "$XDG_RUNTIME_DIR/libvirt/libvirt-sock"); + if (privileged) + fprintf(stderr, " %s\n", + LOCALSTATEDIR "/run/libvirt/libvirt-sock-ro"); + fprintf(stderr, "\n"); + + fprintf(stderr, " %s:\n", _("TLS")); + fprintf(stderr, " %s: %s\n", + _("CA certificate"), + privileged ? LIBVIRT_CACERT : "$HOME/.pki/libvirt/cacert.pem"); + fprintf(stderr, " %s: %s\n", + _("Server certificate"), + privileged ? LIBVIRT_SERVERCERT : "$HOME/.pki/libvirt/serverce= rt.pem"); + fprintf(stderr, " %s: %s\n", + _("Server private key"), + privileged ? LIBVIRT_SERVERKEY : "$HOME/.pki/libvirt/serverkey= .pem"); + fprintf(stderr, "\n"); + + fprintf(stderr, " %s:\n", + _("PID file (unless overridden by -p)")); + fprintf(stderr, " %s\n", + privileged ? LOCALSTATEDIR "/run/libvirtd.pid": + "$XDG_RUNTIME_DIR/libvirt/libvirtd.pid"); + fprintf(stderr, "\n"); } =20 int main(int argc, char **argv) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list