From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18375 invoked from network); 12 Oct 2021 16:05:07 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Oct 2021 16:05:07 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1634054707; b=ri1DoUKJedgD3SV2FCvizjZS67d2hKow2ZYajCNjNCLXVad1kkPdsRvZJZStcTPYpIAXRRp8tC 2SS9DG36AYzOJuFyEoXEoX07sAV/8+OKp1I457FIXnHMiXA0dvCIvlI7RJrcmy+aDqmuoa22dk ktvExYnuXjte4vM0cnkMyTN1mk7bIvQlbfPTu8bJzpGyoTlXMEIr4JVVk2FKc4WuLHP56CNk1X aHypg5n2ltJ84r4h3NF3uv0GX2FHSy4QVciBCK63yz+gIbXOYfWtw1SXd5UgfxrX3gYEK3lYbY JKHiXj/mRcVnPLs8nDV4ZORleoXAQAVs873mIVVMz66x+g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1634054707; bh=pLvGPhYPZYl0G7TpFXHMVWrEgSUoLQuIe/DGzKcl85w=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=kxcLNrYR8zhhhUwhSj/iglSmDQKSip+lWKa2FI36di5eUc5Fge2WNM2vuug4WZzUsgIL+1/v4n zhdlQ4o4TToqALcQdUN5Y/yB2jN8Nh67YTbsG+vBZsP6macJOrWZiQWUHlAK9r1kSFY6RhcjyC h/f2pwXk4aCuXpLpHhZZa2ivBimCRnQpUCZbhQ2TgTiBF+Dp292/gryW+y3Guk+ZqpGSOGZg6q 2nlzCnv5x4lb9Z0NoqpksbOtO/5cq4SlxBWkWb1T64t796MYNL3BgpEXYQzXQ4v2ezYOgMx5Br H24yL6WV1GhZZzYJ1kxdfycG35CgakWMlq4kzZ9vBmjTJg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=pTAjaPw6qbgMPBuJQRfTBBy632Bo2fnj3ucNEOaIqXA=; b=YnPQnNdtteh6c476+MjcVsM6aJ VkOaP8GKmKUb8hHa4xKpfia3GsDXPhn+shEOC+6jrhMdBBh7xmhuaSGtnsuw8/bCmse5enPhXG0UP 7CqhGVyA2/A4mM208ahnZQaV8eltKjTQGBb/eiO4Hq2iJGNSUE6VU3pjGyIQjWNANpI8jAjLiLHDM 1T5ECNQpvSbnu3UnCv5xKc33lwUv/G6PoXgv7Uri/yVwqPMQ14PsAwUbw8RiMGbP1i77lJ0PZCqEY 6KA0li/aFhyd/9J/K5y+0aJfqUPN1rDa5SrZVRmMxO5a9XyNc9MhF6XhoHKpLvURsIuhIaV8UClUp Rw23tXFQ==; Received: from authenticated user by zero.zsh.org with local id 1maKH4-000NhX-3G; Tue, 12 Oct 2021 16:05:06 +0000 Authentication-Results: zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out4-smtp.messagingengine.com ([66.111.4.28]:48411) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1maKGV-000NNw-SX; Tue, 12 Oct 2021 16:04:33 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id E106D5C00C6; Tue, 12 Oct 2021 12:04:30 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 12 Oct 2021 12:04:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm1; bh=pTAjaPw6qbgMPBuJQRfTBBy632Bo2fnj3ucNEOaI qXA=; b=jxsBS7ZH6azgBqpoOaj9+Xv6tiBSXJGms+atb8Tjr2q4+abmC7o4wk+Z st9lBez4RYCzqLSpmgZJGmHtPV8npWyhwQOTKDSB2H6kUaa0yCnUA3XiVoiDkWwz N9WWAVekJtocIxmuyJ981184/bTHfVp+blji/PiSDvu4U/6PgD1vCHGC7BOHmL9u n0MVsIIigycWMIDR/plbFyv+xW1tF112qMDvoYN8a7T8ybVwqQTTXhZtdnkU2lrT fddXPdivhwiD7xYPr/OSQgl2PhZz8nggQ8x3KQlXVhq7rfyxG2ylFRRRbzhsY56n gFPDfzwaHA/ZC14TcUeqCUEUI3DxDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=pTAjaPw6qbgMPBuJQRfTBBy632Bo2fnj3ucNEOaIq XA=; b=PBbubRIRsjtwr7JkJnUEfLPTxAcx4GmfhRwF43viyTmIpMpgFEWcwhW9j t7QuiD1jJy6IhcUWTYCRFSKtqZIiwDkzTyFHpgcNmdsCinwfogkKtM6r1yONmbHV xs75O/8117VXYXSqSsq/JhJ1a1wHd416/a9IkcZ7ztxUdtxP76ydiJAb399tF1az mkP+cfnTWD9lY+nJYIWkc0Sk8Z/uJpkyFCBoTzfcl5k9/e01SmbxXlDqRY5AsFQ1 /0nIpI5hmk3ap+hfsFVYND9VWuj7fqae5ciT8yh3mZ1u/BkABCTMzlhPPsJbm2a4 3e4Dq9h/8M/ByisQlT5S+G7h1QATA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddtkedgleefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggugfgjfgesth ektddttderudenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurdhssegurghn ihgvlhdrshhhrghhrghfrdhnrghmvgeqnecuggftrfgrthhtvghrnhepgfelhedtffeuhf egueelfeffjeegtddtleehvddvueeihfevgfdvgffhvedvkeetnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrdhshh grhhgrfhdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 Oct 2021 12:04:30 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4HTL8D3CY6z3H3; Tue, 12 Oct 2021 16:04:28 +0000 (UTC) Date: Tue, 12 Oct 2021 16:04:28 +0000 From: Daniel Shahaf To: "Jun. T" Cc: zsh-workers@zsh.org Subject: Re: How about separating "_arguments --" into a new function? Message-ID: <20211012160428.GD17948@tarpaulin.shahaf.local2> References: <4B74EF96-AE73-4D40-ACDD-9999DFFDA1A8@kba.biglobe.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4B74EF96-AE73-4D40-ACDD-9999DFFDA1A8@kba.biglobe.ne.jp> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 49477 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Jun. T wrote on Sat, Oct 09, 2021 at 01:12:42 +0900: > _gnu_generic works rather well for basenc, and '_arguments --' > caches the option specs generated from the --help text in a variable > _args_cache_basenc. So I created _basenc by > > % compdef _gnu_generic basenc > % basenc > % echo ${(F)${(qqq)_args_cache_basenc}} > _basenc > and edited _basenc (to add option groups etc.). > Nice :) > If we separate the part of _arguments that generates the option specs > (around lines 36 - 323) into an auto-loadable function, say help2specs, > then we will be able to do something like > > % help2specs cmd > _cmd > (and edit _cmd to improve it) > > If this seems useful I'll work on it. A tool that takes some command's --help output and produces a skeleton completion function would certainly be nice for people writing completion functions. However, creating a new completion function isn't a common task; I suspect it's more common to update an existing completion function with more custom logic or with new options. So, perhaps the tool could be designed with an eye towards updating existing completion functions? For instance, perhaps the tool could inspect the existing _cmd file and omit from the output any lines where the --foo[lorem ipsum] part already appears in the file? Perhaps make the tool a filter, in order to support, say, «ssh foo 'lorem --help' | help2specs»? The docs of _arguments say one should declare «local context state state_descr line; typeset -A opt_args» whenever one uses -> actions. Some tool (not necessarily the same tool as the proposed help2specs tool) that prefills those lines would be nice to have: that would prevent people from forgetting or overlooking those declarations, and having them prefilled would be easier than copying them from the manual. > Or just using $_args_cache_cmd is enough? If it is enough, then it should be made more discoverable. > If _arguments is separated into two, tracing the history by 'git blame' > etc. would be a little bit tedious. Well, yes, but on the other hand, _arguments would then be "doing one thing and doing it well", and its documentation would be clearer. And _arguments' own source code might be clearer too. (I don't have a strong opinion; I'm just playing Devil's advocate.) Of course, if _arguments does get splitted, it may then be needed to update __arguments. Cheers, Daniel