Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rD4f5-000pA9-DX for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Dec 2023 15:27:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rD4f4-005rGI-5C for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Dec 2023 15:27:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rD4f3-005rG9-Qy for pgsql-hackers@lists.postgresql.org; Tue, 12 Dec 2023 15:27:05 +0000 Received: from mail-oo1-xc35.google.com ([2607:f8b0:4864:20::c35]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rD4f0-00BbNP-Jf for pgsql-hackers@postgresql.org; Tue, 12 Dec 2023 15:27:05 +0000 Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-58dd3528497so3511840eaf.3 for ; Tue, 12 Dec 2023 07:27:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=neon.tech; s=google; t=1702394820; x=1702999620; darn=postgresql.org; h=in-reply-to:references:from:to:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sdh9+lr3rlXwl/DkX0FLAMDORkh1LTG/ctDDs2MGojk=; b=JbR2sJEIQzXsev4k/kDLf/mkPf42UfeiwIIrARYI8882xeqnzESm0A2+eh5PBXEW99 ca9cjSVU2Eejl3HWpYfq26JeUbPaYG1RtdJImXKnARptQs6q2WKzQ8yAd8/U6+XcmrEy WbePDD0jNVGn7XP+GnaNRHPMAP4pkKSvvwDRE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702394820; x=1702999620; h=in-reply-to:references:from:to:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=sdh9+lr3rlXwl/DkX0FLAMDORkh1LTG/ctDDs2MGojk=; b=gvKqHMtheMue7ul1JNZg4xpyUgBIEiGFG+pe5AA2syXcDp1ciFr+sfa4DjaMjDGcsc fnLGhU0ZubAx0/l8ie9CMi5nPVsbY4TfhT722rmZ5Yp2cnjwX/0Ye9dRWZ0SZTsyaTbQ uplucIQgWYOp9Io8wtQ0nv/YuQvMpasraA/Po3yzDXw4bum1GLFbzxZIQKLWupzgZm7F RCMMlGCRPhttGC12K6JfX/UOs7cwe9whrAvZPXTUAaKBNvycjIIJjnjfiCCdu9mBL/Qq 8q6T0ic+pWJtt2wsPaOm/P2EVfkQ7J8peXCYmpmald3jymyQacZDiBCCY+lpwSHZ3vSz 6s0Q== X-Gm-Message-State: AOJu0YwMCdPrM7lAXGqMbfxCwIZf7wfCv9nk4EjasOMT5KFpVVrooZmu 74JG+V4tDtITz9Xkj5TKJr4GEg== X-Google-Smtp-Source: AGHT+IEWZaoUVqIZe8I4sN8C+JesZPYX4CqBW2WoBcsF2aCA6yV7Vp/aZsSBw0M1idwhKpVNoxRhEA== X-Received: by 2002:a05:6870:288f:b0:1fa:e63b:91fa with SMTP id gy15-20020a056870288f00b001fae63b91famr9127596oab.40.1702394820016; Tue, 12 Dec 2023 07:27:00 -0800 (PST) Received: from localhost ([2607:fb90:e64f:544c:3996:e070:71ee:42fb]) by smtp.gmail.com with ESMTPSA id h16-20020a9d7990000000b006d9d8abcdeesm2279744otm.40.2023.12.12.07.26.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Dec 2023 07:26:59 -0800 (PST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8; format=Flowed Date: Tue, 12 Dec 2023 09:26:58 -0600 Message-Id: Cc: "pgsql-hackers" Subject: Re: Add --check option to pgindent To: "Euler Taveira" , "Michael Banck" , "Daniel Gustafsson" From: "Tristan Partin" X-Mailer: aerc 0.16.0-88-g66b9d36b9231 References: <657835bb.500a0220.a88d.2058@mx.google.com> In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue Dec 12, 2023 at 5:47 AM CST, Euler Taveira wrote: > On Tue, Dec 12, 2023, at 7:28 AM, Michael Banck wrote: > > On Tue, Dec 12, 2023 at 11:18:59AM +0100, Daniel Gustafsson wrote: > > > > On 12 Dec 2023, at 01:09, Tristan Partin wrote: > > > >=20 > > > > Not sold on the name, but --check is a combination of --silent-diff > > > > and --show-diff. I envision --check mostly being used in CI > > > > environments. I recently came across a situation where this behavio= r > > > > would have been useful. Without --check, you're left to capture the > > > > output of --show-diff and exit 2 if the output isn't empty by > > > > yourself. > > >=20 > > > I wonder if we should model this around the semantics of git diff to > > > keep it similar to other CI jobs which often use git diff? git diff > > > --check means "are there conflicts or issues" which isn't really > > > comparable to here, git diff --exit-code however is pretty much > > > exactly what this is trying to accomplish. > > >=20 > > > That would make pgindent --show-diff --exit-code exit with 1 if there > > > were diffs and 0 if there are no diffs. > >=20 > > To be honest, I find that rather convoluted; contrary to "git diff", I > > believe the primary action of pgident is not to show diffs, so I find > > the proposed --check option to be entirely reasonable from a UX > > perspective. > >=20 > > On the other hand, tying a "does this need re-indenting?" question to a > > "--show-diff --exit-code" option combination is not very obvious (to me= , > > at least). > > Multiple options to accomplish a use case might not be obvious. I'm wonde= ring > if we can combine it into a unique option. > > --show-diff show the changes that would be made > --silent-diff exit with status 2 if any changes would be made > + --check combination of --show-diff and --silent-diff > > I mean > > --diff=3Dshow,silent,check > > When you add exceptions, it starts to complicate the UI. > > usage("Cannot have both --silent-diff and --show-diff") > if $silent_diff && $show_diff; > =20 > +usage("Cannot have both --check and --show-diff") > + if $check && $show_diff; > + > +usage("Cannot have both --check and --silent-diff") > + if $check && $silent_diff; > + I definitely agree. I just didn't want to remove options, but if people=20 are ok with that, I will just change the interface. I like the git-diff semantics or have --diff and --check, similar to how=20 Python's black[0] is. [0]: https://github.com/psf/black --=20 Tristan Partin Neon (https://neon.tech)