facebook / facebook/buck2

UI request: a shorthand for 'buck bxl' invocations (or: arbitrary 'buck foobar' commands)

Open
#86 9 comments 2 reactions 0 assignees View on GitHub
bxl enhancement
Dominant language
Rust
Stars
4.4k
Forks
394
PR merge metrics
No merged PRs in 30d

Description

Here's a nifty one-liner I put behind the name `bxl`:

```bash
exec buck2 bxl "bxl//top.bxl:$1" -- "''${@:2}"
```

This requires you to:
- set `bxl = path/to/some/dir` in your root `.buckconfig` file `[repository]` stanza, and then
- export a bunch of top level `bxl()` definitions from `bxl//top.bxl` which can be invoked

Then you can just run the command `bxl hello --some_arg 123` in order to run an exported `bxl()` definition named `hello`. Pretty nice! And because the command invocation uses the `bxl//` cell to locate `top.bxl`, the `bxl` 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 allows `git foobar` to invoke the separate `git-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 a `buck2 foobar` subcommand is useful for the same reasons. So maybe that's a better place to start, and the `bxl` scripts could be a more specialized case of this.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.