From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:203:b4db::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id OIMFCG/0zGFjYgAAsNZ9tg (envelope-from ); Wed, 29 Dec 2021 23:51:11 +0000 Received: from out0.migadu.com ([2001:41d0:2:267::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id YHlRB2/0zGE8KgEA9RJhRA (envelope-from ); Thu, 30 Dec 2021 00:51:11 +0100 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1640821870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6+Zm+aDkNLsTwfHQKNEqB7MmkjJuMApWxZdKvcawjVM=; b=NA34remE41NwBJBzkEKZAsfek5+ov57loImp5Gmf2Tx70W7D38KoU1B5cPjC8YcWIDQZvE xf87NRVufcCDKOTlfBD6FFibWd+CtXnK/7ifytiMdYleq+aZLwq/zI/KPNoxMVLvRm/PXu rpMnKLY1cr5VI/X+DwIO6aV3vIw5Cfrh2oGWkmUKQ8Ea+GLG1h2wtTLKk1fyvNjqdkZ43x 65ykvLWojDIIH1nj7cD90c6Oav3raZxINkA75+8LHyqEotbpRNszeG4uC58zFojzS4deoY lMOUlzf3tDiymc7CHQlbCdhGNmG1x3gHWivoCrKX5ZPt7Gmvytm9uCUx8VDalA== From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [RFC PATCH 11/14] b4: Move logic for checking arguments to a dedicated function Date: Wed, 29 Dec 2021 18:50:33 -0500 Message-Id: <20211229235036.372313-12-kyle@kyleam.com> In-Reply-To: <20211229235036.372313-1-kyle@kyleam.com> References: <20211229235036.372313-1-kyle@kyleam.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: kyleam.com X-TUID: 9u/kd0EbTyT7 The new -extend variant will need to do the same check. --- piem-b4.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/piem-b4.el b/piem-b4.el index d2370124..48836eb2 100644 --- a/piem-b4.el +++ b/piem-b4.el @@ -127,6 +127,17 @@ (defun piem-b4-am-ready-from-mid (mid &optional args) (apply #'piem-process-start nil piem-b4-b4-executable "am" (append args (list mid)))) +(defun piem-b4-am--check-args (args) + (when-let ((badopt (cl-some + (lambda (arg) + (and (string-match + (rx string-start + (group (or "--outdir" "--mbox-name")) "=") + arg) + (match-string 1 arg))) + args))) + (user-error "%s is incompatible with this command" badopt))) + ;;;###autoload (defun piem-b4-am-from-mid-create (mid &optional args toggle-worktree) "Create a new branch with patches extracted from MID's thread. @@ -148,15 +159,7 @@ (defun piem-b4-am-from-mid-create (mid &optional args toggle-worktree) (read-string "Message ID: ")) (transient-args 'piem-b4-am) current-prefix-arg)) - (when-let ((badopt (cl-some - (lambda (arg) - (and (string-match - (rx string-start - (group (or "--outdir" "--mbox-name")) "=") - arg) - (match-string 1 arg))) - args))) - (user-error "%s is incompatible with this command" badopt)) + (piem-b4-am--check-args args) (pcase-let* ((coderepo (piem-inbox-coderepo-maybe-read)) (`(,cover ,mbox-file ,clean-fn) (piem-b4--get-am-files mid coderepo args)) -- 2.34.0