I was hacking around this - <https://pantsbuild.sl...
# development
m
I was hacking around this - https://pantsbuild.slack.com/archives/C0D7TNJHL/p1638423622110100?thread_ts=1638346952.082700&amp;cid=C0D7TNJHL And I have something working but I have a few questions: 1. I have an address and I want to get a target from it, what API should I use? 2. My goal_rule accepts two addresses (which I verify) but I get them in sorted order and not in the input order, is there a way around this? 3. Is there a mixin line LineOriented for JSON?
c
I can take a stab at this, until @witty-crayon-22786 wakes up. 1. You can`await Get(WrappedTarget, Address, my_address)` 2. I can think of two workarounds: a) If there are no link from tgt1 to tgt2, try again with the order reversed. or b) have one of the targets as an option instead:
./pants graphs --from-target=tgt1 tgt2
3. I’ve got no answer for this one.
m
Actually I also get implicit addresses as well 😐 I pass
subdir/a.py
subdir/b.py
and I get in the goal 3 addresses
subdir/a.py
subdir/b.py
subdir:main
@curved-television-6568 is there a special option for an address?
Copy code
meta=address
or something?
c
Ah, I think that
subdir:main
is the generator for those other two.. not sure why it shows up, though.. guess that’s an implementation detail. Perhaps you only want to work with file targets, though.. so you could filter those addresses on
addr.is_file_target
( https://github.com/pantsbuild/pants/blob/main/src/python/pants/build_graph/address.py#L288 )
is there a special option for an address?
meta=address
or something?
Don’t understand this question..
m
If I add an option for the
--from
is the option builder for address
c
Oh, right, now I get it
m
And what’s the way to resolve a string to an address?
c
I don’t think there is.. but you can go from an unparsed raw string to an adress or target:
await Get(Targets, UnparsedAddressInputs, unparsed)
m
👀 1
🙌 1
👍 1
c
That looks great!