-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI request: a shorthand for 'buck bxl' invocations (or: arbitrary 'buck foobar' commands) #86
Comments
It's great that Bxl is turning out to be so useful. Having
Or something of that form - so you can essentially introduce top-level command aliases to buck2. I could imagine defining |
Yes, I think that something like that is the right way forward, but I didn't want to get too far ahead of myself! A big advantage of having it in the |
Here's something I just thought of: if a command is exposed as a I think this is highlighting is that the I point this out because I think part of the build system is having a great UX. Here's a more worked example of what I'm thinking of. Let's say
Then, """A command that runs bxl scripts, conveniently"""
def _impl(ctx):
# NOTE: execute `buck2 bxl bxl//${target}.bxl:${target} -- ...` similar to the alias
_args = {
"target": cli_args.option(cli_args.target_label())
}
main = bxl(impl = _impl, args = _args) # for `[commands]` stanza
brun = bxl(impl = _impl, args = _args) # for `brun-less` to work All of the following commands now work:
This is a contrived example but I think you see what I'm getting at. The semantics are something like:
Some notes:
At this point if this could work, the rest mostly falls into place. Final notes:
|
Cool, I'll raise this and #85 with the larger team internally and encourage people to comment here. |
Was there any commentary from the internal team on this feature? As discussed in #263 we are running into some real world use cases where this could be a nice addition. |
@ndmitchell Has anything come out of those internal discussions? Would you accept a patch that would add support for aliases, at least as a first step? |
Here's a nifty one-liner I put behind the name
bxl
:This requires you to:
bxl = path/to/some/dir
in your root.buckconfig
file[repository]
stanza, and thenbxl()
definitions frombxl//top.bxl
which can be invokedThen you can just run the command
bxl hello --some_arg 123
in order to run an exportedbxl()
definition namedhello
. Pretty nice! And because the command invocation uses thebxl//
cell to locatetop.bxl
, thebxl
command can work in any repository that defines that cell, and the files can be located anywhere.So my question is: could something like this be supported in a better way? The reason is pretty simple: it's just a lot easier to type and remember!
Perhaps the best prior art here I can think of is
git
, which allowsgit foobar
to invoke the separategit-foobar
binary, assuming it's in$PATH
and has an executable bit set. We don't need to copy this exactly 1-to-1, but it's a generalized solution to this problem, and in fact it's arguable that being able to do abuck2 foobar
subcommand is useful for the same reasons. So maybe that's a better place to start, and thebxl
scripts could be a more specialized case of this.The text was updated successfully, but these errors were encountered: