Add a subcommand that prints out a space-separated list of the names of
top-level variables in the justfile.
The syntax is:
$ just --variables
a b c
This can be used for any purpose, but is mostly intended for completion
scripts, so that they can get the names of variables without using
`--evaluate`.
Additionally:
- Add `bin/generate-completions` script to regenerate checked-in
completions
- Update dependencies
- Regenerate checked-in completions
Make just print clap-generated shell completion scripts with `--completions`
command. Currently, Bash, Zsh, Fish, PowerShell, and Elvish are supported.
Additionally, the generated completion scripts are checked in to the
`completions` folder.
Add the `--shell-arg` and `--clear-shell-args` flags, which allow
setting and clearing arguments to the shell from the command line.
This allows full control over the shell from the command line. Additionally,
any shell-related arguments on the command line override
`set shell := [...]` in the Justfile, which I think will be the behavior that most
people expect.
When `--init` is passed on the command line, search upward for the
project root, identified by the presence of a VCS directory like `.git`,
falling back to the current directory, and create a default justfile in
that directory.
Add a `set SETTING := VALUE` construct.
This construct is intended to be extended as needed with new settings,
but for now we're starting with `set shell := [COMMAND, ARG1, ...]`,
which allows setting the shell to use for recipe and backtick execution
in a justfile.
One of the primary reasons for adding this feature is to have a better
story on windows, where users are forced to scrounge up an `sh` binary
if they want to use `just`. This should allow them to use cmd.exe or
powershell in their justfiles, making just optionally dependency-free.
This diff makes positional argument parsing much cleaner, along with
adding a bunch of tests. Just's positional argument parsing is rather,
complex, so hopefully this reform allows it to both be correct and stay
correct.
User-visible changes:
- `just ..` is now accepted, with the same effect as `just ../`
- `just .` is also accepted, with the same effect as `just`
- It is now an error to pass arguments or overrides to subcommands
that do not accept them, namely `--dump`, `--edit`, `--list`,
`--show`, and `--summary`. It is also an error to pass arguments to
`--evaluate`, although `--evaluate` does of course still accept
overrides.
(This is a breaking change, but hopefully worth it, as it will allow us
to add arguments to subcommands which did not previously take
them, if we so desire.)
- Subcommands which do not accept arguments may now accept a
single search-directory argument, so `just --list ../` and
`just --dump foo/` are now accepted, with the former starting the
search for the justfile to list in the parent directory, and the latter
starting the search for the justfile to dump in `foo`.
- Instead of changing the current directory with `env::set_current_dir`
to be implicitly inherited by subprocesses, we now use
`Command::current_dir` to set it explicitly. This feels much better,
since we aren't dependent on the implicit state of the process's
current directory.
- Subcommand execution is much improved.
- Added a ton of tests for config parsing, config execution, working
dir, and search dir.
- Error messages are improved. Many more will be colored.
- The Config is now onwed, instead of borrowing from the arguments and
the `clap::ArgMatches` object. This is a huge ergonomic improvement,
especially in tests, and I don't think anyone will notice.
- `--edit` now uses `$VISUAL`, `$EDITOR`, or `vim`, in that order,
matching git, which I think is what most people will expect.
- Added a cute `tmptree!{}` macro, for creating temporary directories
populated with directories and files for tests.
- Admitted that grammer is LL(k) and I don't know what `k` is.
Just's first parser performed both parsing, i.e the transformation of a
token stream according to the language grammar, and a number of consistency
checks and analysis passes.
This made parsing and analysis quite complex, so this diff introduces a
new, much cleaner `Parser`, and moves existing analysis into a dedicated
`Analyzer`.
- Refactor the lexer tests to be more readable, abandoning the
previous string-based summary DSL in favor of a more obvious
sequence of `TokenKinds` with optional lexemes. The new tests
also test that token lexemes are correct.
- Move duplicated `unindent` function into a shared crate,
`test-utilities`. This new versionless dev-dependency will
prevent publishing to crates.io, at least until rust-lang/cargo/pull/7333
makes it into stable. If we publish a new version before then,
test-utilities will need to be published to crates.io, so we can depend
on it by version.
Since error code 1 is commonly used to indicate failure, change those
integration tests which test that a specific error code is returned to
use something other than 1.
Adds an `unindent()` function that strips common leading indentation
from strings, and apply it to integration test case strings, so that they
can be written in a more readable style.
This commit changes the integration tests to run with bash
as the shell, instead of bash, dash, and the system's sh.
Running the integration tests with multiple shells has never
revealed a bug in Just, and they make the tests take longer,
so let's get rid of them.
Previously, warnings upon encountering a deprecated use `=` in
assignments, exports, and aliases would print a message without any
indication of where the offending `=` was. This diff adds a proper
`Warning` enum, and uses it to report context, as is done with
compilation and runtime errors.
Given the following justfile:
alias b := build
build:
echo 'Building!'
Just will show the alias along with the recipe:
$ just --show b
alias b := build
build:
echo 'Building!'
Just's dependency on brev was the cause of a
fairly deep branch of the transitive dependency
tree. To decrease build time and make the life of
packagers easier, this diff moves the functionality
that Just was using in Brev into Just itself, and
removes the dependency on Brev.
Fortunately, the only functionality that Just was
using was the output function and OutputError
enum, so this was easily done.
Integration tests run with bash, dash, and whatever's installed as `sh`, to ensure compatibility with a wide range of systems.
This commit changed the way that dash escapes special characters, which broke the integration tests:
https://git.kernel.org/pub/scm/utils/dash/dash.git/commit/?id=6900ff60ef7347a8c1445853a8f4689808e0976e
This commit modifies our tests to be compatible with dash before and after the changes, and should fix the Travis build.
The invalid escape sequence error message is delimited with backticks
and isn't used as input to other programs. This diff tweaks the escaping rules
slightly when printing invalid escape sequences. In particular, `, \, ',
and " are now not be escaped.
`env_var(key)` looks up the value of the environment variable with name `key`, aborting execution if it is not found.
`env_var_or_default(key, default)` looks up the value of the environment variable with name `key`, returning `default` if it is not found.