Commit Graph

30 Commits

Author SHA1 Message Date
Casey Rodarmor
30c77f8d03
Resolve recipe dependencies (#547)
Make analysis resolve recipe dependencies from names (`Name`) to recipes
(`Rc<Recipe>`), to give type-level certainty that resolution was performed
correctly and remove the need to look up dependencies on run.
2019-11-21 08:23:32 -06:00
Casey Rodarmor
72bc85e4ea
Un-implement Deref for Table (#546)
Remove `Deref` implementation for `Table`, to make sure we're using
`Table` and not `BTreeMap`.
2019-11-20 16:19:49 -06:00
Casey Rodarmor
c4e9857ebd
Avoid fs::canonicalize (#539)
Previously, we used `fs::canonicalize` to ensure paths used in search
were absolute. This lead to bad behavior when the justfile was symbolic
link to a file in another directory. Additionally, on Windows, this
produced paths in extended length syntax, which, I believe, has
compatibility issues.

This diff replaces uses of `fs::canonicalize`  with a simpler algorithm
that roots path in the invocation directory (which will be a no-op if
said path is already absolute), uses `Path::components` to remove extra
`/` and `.`, and resolves instances of `..` without following symlinks, by
removing the `..` and the component that proceeds it.
2019-11-19 03:51:44 -08:00
Casey Rodarmor
598f1c3200
Refactor Compilation error to contain a Token (#535)
Use a `Token` to represent the error context, instead of a mess of
fields. Remove write_message_context in favor of `Token::write_context`.
2019-11-13 19:32:50 -08:00
Casey Rodarmor
e80bf34d9a
Add shell setting (#525)
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.
2019-11-10 23:17:47 -08: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
b2285ce0e0
Reform Parser (#509)
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`.
2019-11-07 10:55:15 -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
3de31b3c02
Remove misc.rs (#491)
Put everything that was in `misc.rs` into their own files, with some opportunistic
refactoring, because why not.
2019-10-09 01:40:40 -07:00
Casey Rodarmor
ca4f2a44ed
Refactor run::run and Config (#490)
Improve color parsing, add `ConfigError`, put `invocation_directory` on Config object, return error code from `run::run` instead of exiting.
2019-10-09 00:18:53 -07:00
Casey Rodarmor
ab11740104
Add explicit Subcommand enum (#484) 2019-10-07 04:04:39 -07:00
Casey Rodarmor
2938ab1561
Start pulling argument parsing out of run::run() (#483)
run::run() is pretty unwieldy. As a first step in improving it, this
commit pulls most of the argument parsing into the `config` module.

It also renames `Configuration` to `Config`, just to be easier to type.
2019-10-07 02:06:45 -07:00
Casey Rodarmor
1230af138c
Add context to deprecation warnings (#473)
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.
2019-09-21 18:53:30 -07:00
Casey Rodarmor
1cb90f4e65
Use pub(crate) instead of pub (#471)
Eventually, there will probably be a `crate` visibility specifier that
does the same thing as `pub(crate)`. This commit replaces `pub` with
`pub(crate)`, so when `crate` is available we can easily switch to it.
2019-09-21 15:35:03 -07:00
Casey Rodarmor
1d3235780a
Make comments in common.rs lowercase (#470) 2019-09-15 01:29:11 +02:00
Casey Rodarmor
74e45e7c05
Remove dependency on brev (#462)
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.
2019-07-13 01:55:06 -07:00
Niklas Claesson
ff91e3d7c6 Use tempfile crate instead of tempdir (#455) 2019-07-06 20:55:46 -07:00
Rostyslav Shevtsiv
7f06bc68d4 Ignore file name case while searching for justfile (#436) 2019-06-01 22:38:02 -07:00
Casey Rodarmor
9c82a1e329
Move CompilationErrorKind into separate module (#416) 2019-04-19 02:40:25 -07:00
Casey Rodarmor
415c84ea39
Refactor and rename test macros (#415) 2019-04-19 02:17:43 -07:00
Casey Rodarmor
596ea34460
Replace regex-based lexer with character-at-a-time lexer (#406) 2019-04-15 22:40:02 -07:00
Casey Rodarmor
3a287b864a
Housekeeping (#394)
- Upgrade to rust 2018
- Update dependencies
- Use BTree{Map,Set} instead of Map and Set
2019-04-11 15:23:14 -07:00
ryloric
f64f07a0cc Add recipe aliases (#390)
Recipe aliases may be defined with `alias f = foo`, allowing recipes to be called by shorter names on the command line.
2019-04-11 12:30:29 -07:00
Casey Rodarmor
3d67786aaf
Förmatterdämmerung (#346)
Format with rustfmt
2018-12-08 14:29:41 -08:00
Casey Rodarmor
816183b975
Add grandiloquent verbosity level that echos shebang recipes (#348) 2018-08-31 00:04:06 -07:00
Casey Rodarmor
4e6585d391
Slake Clippy's thirst for blood (#347) 2018-08-27 18:36:40 -07:00
Casey Rodarmor
b14d1ec97c
Wait for child processes to finish (#345)
Thanks to @bheisler for the feature request and initial implementation.

Fixes #302
2018-08-27 16:03:52 -07:00
Casey Rodarmor
68b343bc17
Make .env vars available in env_var functions (#310) 2018-03-17 09:17:41 -07:00