Pants TOD (Tip Of the Day): If you ever felt like...
# general
Pants TOD (Tip Of the Day): If you ever felt like it would be nice if Pants had this little extra feature.. but don’t want to invest in writing a custom plugin to implement another goal? Todays tip will present an alternative approach that gives the same feel but with a very lightweight integration. Consider this UX:
Copy code
$ ./pants my-feat --help
Usage: python -m my-feat [OPTIONS]

This is possible by using
and a
target some where in your first party code base (could be a utility tree living outside your regular application code, it just needs to be in a source root).
Copy code
my-feat = "run src/utils/ --"
Then in
Copy code
pex_binary(.., entry_point="")
Then implement
as any regular cli tool, using
or what makes most sense to you.
👍 1
🙌 5
Yes, I've used this a bunch! Great tip
🎉 1
Putting these in a separate resolve is also a pro-tip
👍 1
Fun hack!!
Actually, worth a blog post I think?
(I actually have a macro for the resolve+target boilerplate)
"Tip of the Day", I love this! Andreas, it is okay to copy this tip into a blog post? You can feel free to expand on it, or not, for the blog version.
Maybe we can collect these somewhere and leak them periodically. Then after some time make a blog post of the leaked ones?
I know I have a few 😛
Also back-on-topic I think your post is best compared to a tool like
which is used for sandboxing CLI tools. Pants' approach is spiritually equivalent, but can be shared across machines in the monorepo. We do this for things like
When a tip is conducive to bein\
(sorry, puppy crossed the keyboard hahaha) When a tip is conducive to being tweeted, that's a good way to distribute it. Then I can RT it from the Pants account, which ensures it also shows up in the slack. Then as they accumulate I can repackage into a blog post as well. Hits a bunch of media collectively, from the original person just tweeting once. It'd be good to pick a hashtag for this
looks wonky to me for some reason. Anything without "build", e.g.
risks being interpreted by twitter as a fashion topic, unfortunately.
👖 1
💵 1
🐶 2
👍 1
Terrific! In the future, if one namechecks the
account anywhere within the tweet I'll get notified automatically. One less step for y'all to do, plus readers can jump right to additional pants content.
I'm still learning Twitter
Everyone is. Especially the people at Twitter itself, so you're in great company!
hmm… I feel my tip may have been a tad long for twitter… 😛
No, it's good!
It's exactly what threading is for.
OK, so it would be a feature request for Twitter then, to automatically split up long messages like that.. but I guess they want to discourage longish messages overall to keep the majority short and succinct.
I think I'll retweet mine with the Pantsbuild account
wait nevermind 😛