https://pantsbuild.org/ logo
#general
Title
# general
h

hundreds-father-404

05/24/2022, 4:37 AM
I got ignore CLI args working, so you can do
./pants test project:: '!project/integration_test::'
šŸŽ‰ The issue is that you have to quote the
!
or your shell won't be happy. So @curved-television-6568 suggested instead using
-
, like
-project/integration_test::
, which mirrors how
--tag
works. However, that causes ambiguity with short-flags like
-dmy_custom_dir
, which equals
--logdir=my_custom_dir
. How do people feel about getting rid of *the ability for arbitrary short flags, to make room for ignore CLI args?
āœ… 1
We only have a few short flags atm: ā€¢
-l
, aka
--level
ā€¢
-d
, aka
--logdir
. Which doesn't look like it actually is wired up to anything... ā€¢
-h
, aka
--help
ā€¢
-v
, aka
--version
*I think some of those are good, especially
-h
and
-v
, and maybe
-l
But generally, I believe that short flags are an antipattern w/ Pants, given how many options we have and how many things Pants does Short flags are great with tools that have ~one purpose, like Pex and pip. But with Pants, it's too vague imo
If we really are attached to the brevity of
-ldebug
vs
--level=debug
(6 char difference)...we could special case it in our arg parsing code
Altho I encourage consistency. Fewer things for users to learn My proposal is to special case
-h
,
-v
, and probably
-l
given how frequently it's used But otherwise, get rid of
-d
==
--logdir
and ban short args for plugin authors
c

curved-television-6568

05/24/2022, 5:00 AM
Another observation here is that from what I can tell, those short flag options are all bootstrap options, right? So must go before any goals. So we could simply drop shortflag support for subsystems to accommodate negated target specs.
āž• 1
h

hundreds-father-404

05/24/2022, 5:03 AM
My proposal is to special case -h, -v, and probably -l given how frequently it's used
This was easy to get working with
args_parser.py
šŸ™‚ So if people agree w/ the proposal, I'm confident we can implement
c

curved-television-6568

05/24/2022, 5:05 AM
Is it possible to not specialcase those particular flags, but rather pre goal flags vs post goal flags?
h

hundreds-father-404

05/24/2022, 5:06 AM
Possibly. In my implementation so far, I only had to special case
-l
.
-h
and
-v
are already handled by being
BuiltinGoal
This is all it is:
Copy code
if not arg.startswith("--") or arg in {"-linfo", "-lwarn", "-ldebug", "-ltrace", "-lerror"}:
            return False
-d
is an issue tho because it's not an enum and can have an arbitrary value. We'd have to do something like
if arg.startswith('-d')
. But that means we might not recognize the value
-dir
as a spec..., thinking you mean
--logdir=ir
hah
šŸ‘€ 1
fyi, this is all it took to make
arg_parser.py
happy, assuming we are fine removing
-d
and banning plugin authors from using short flags https://github.com/Eric-Arellano/pants/commit/7f66bf4643fb1916b079380c4eed3b6ebda235b8 I would also add validation to
parser.py
that short flags aren't being used beyond the blessed ones of
-l
,
-h
, and
-v
h

happy-kitchen-89482

05/24/2022, 5:37 AM
Yeah I'm fine with this. The 3 you mention are probably important, but we can kill
-d
šŸš€ 1
ā¤ļø 1
b

bitter-ability-32190

05/24/2022, 10:28 AM
Party hard!!!
Just to clarify, how does argparse handle
-
now? In bazel you have to "escape" it,
bazel test //... -- -//foo/...
But that'd mess with passthrough args. Can we get this working without
--
?
c

curved-television-6568

05/24/2022, 10:30 AM
Yep, without
--
b

bitter-ability-32190

05/24/2022, 11:11 AM
Party hard
3 Views