Commit Graph

20 Commits

Author SHA1 Message Date
Casey Rodarmor
1b0fafea75
Add loader and refactor errors (#917)
This commit adds a `Loader` type, which can be used to load multiple
source strings. This was done to support the work on modules, but
coincidentally enabled consolidating errors, since now `Config::run`
can take a `&Loader`, and in the event of an error, return and `Error`
that borrows from loaded strings. Multiple error types have been
consolidated, and a bunch of ad-hoc error printing was removed.
2021-07-26 01:26:06 -07:00
Oleksii Dorozhkin
8677492d56
Add --fmt subcommand (#837) 2021-06-08 01:01:27 -07:00
Casey Rodarmor
50cd24d37b
Add the --command subcommand (#824) 2021-05-10 03:35:35 +00:00
Casey Rodarmor
09b370e10d
Change --eval to print variable value only (#806) 2021-04-25 17:02:57 -07:00
Casey Rodarmor
d03aedd5c4
Allow filtering variables to evaluate (#795)
If variable names are passed to `--evaluate`, only print those
variables.
2021-04-05 21:50:50 -07:00
Casey Rodarmor
86c2e52dc6
Suppress all output to stderr when --quiet (#771)
Suppress all warnings and error messages when `--quiet` is passed.
2021-03-25 16:51:29 -07:00
Zhenhui Xie
0e1af65565
Allow completing variables and recipes after --set in zsh completion script (#697) 2020-10-17 21:58:44 -07:00
Chris Nantau
fbda8dd2c7
Complete recipes names in PowerShell completion script (#651) 2020-10-05 19:12:48 -07:00
Vikesh Raj
a8361012d6
Complete recipes in bash completion script (#685)
Modifies the bash completion script to complete both recipes and flags.
`just <TAB>` will complete recipes, and `just -<TAB>` will complete
flags and options.
2020-10-05 17:58:30 -07:00
Casey Rodarmor
9d0246998d
Add the --choose subcommand (#680)
The `--choose` subcommand runs a chooser to select a recipe to run. The
chooser should read lines containing recipe names from standard input,
and write one of those names to standard output.

The chooser defaults to `fzf`, a popular fuzzy finder, but can be
overridden by setting $JUST_CHOOSER or passing `--chooser <CHOOSER>`.
2020-09-17 19:43:04 -07:00
Tobin Yehle
fef69a3ec1
Complete recipe names in fish completion script (#625) 2020-05-03 20:35:53 -07:00
Zhenhui Xie
e79482f2dc
Update zsh completion file (#606)
- Complete variable names after `--set`
- Complete recipe names
- Display recipe signature and body below command line
- Modify completions subcommand to produce enhanced zsh completion script
2020-03-16 17:20:14 -07:00
Casey Rodarmor
1dbc765390
Add --variables subcommand that prints variable names (#608)
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
2020-03-13 22:19:43 -07:00
Casey Rodarmor
85e8015702
Generate shell completion scripts with --completions (#572)
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.
2020-01-15 01:20:38 -08:00
Casey Rodarmor
e948f11784
Add --init subcommand (#541)
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.
2019-11-20 01:07:44 -06:00
Casey Rodarmor
177516bcbe
Reform positional argument parsing (#523)
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`.
2019-11-10 18:02:36 -08:00
Casey Rodarmor
aefdcea7d0
Gargantuan refactor (#522)
- 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.
2019-11-09 21:43:20 -08:00
Casey Rodarmor
8279361b39
Move subcommand execution into Subcommand (#514)
Moves the code which executes subcommands into Subcommand:run,
delegating to separate functions for each subcommand. This reduces the
disgustingness of `run::run` a bit, and paves the way for future
refactoring and cleanup.
2019-11-07 13:52:22 -08:00
Casey Rodarmor
48b25c14b1
Use constants instead of literals in arg parser (#504)
- Differentiate between `arg`s, which are flags and options, and `cmd`s,
  which are mutually exclusive subcommands

- Replace string literals, like "EVALUATE", with constants, like
  `cmd::EVALUATE`, since they're slightly less error prone.

- Remove `Config::evaluate`, and handle it like other subcommands
2019-10-31 17:39:25 -07:00
Casey Rodarmor
ab11740104
Add explicit Subcommand enum (#484) 2019-10-07 04:04:39 -07:00