Commit Graph

65 Commits

Author SHA1 Message Date
Casey Rodarmor
c24a194602
Add windows-shell setting (#1198) 2022-05-31 13:01:59 -07:00
Casey Rodarmor
c87909c220
Fix a bunch of typos (#1204) 2022-05-29 02:07:53 +00:00
Greg Lutostanski
bcdaa95a66
Allow duplicate recipes (#1095) 2022-02-15 02:37:06 +00:00
Casey Rodarmor
27cd8fd554
Remove call to sed in justfile (#1078) 2022-01-30 20:16:10 +00:00
Michael Lohr
6cf95a7337
Add windows-powershell setting (#1057) 2022-01-18 19:02:15 +00:00
Casey Rodarmor
8b49c0cbd1
Ignore leading byte order mark in source files (#1021) 2021-11-05 04:35:57 +00:00
Casey Rodarmor
58a196f434
Make join accept two or more arguments (#1000) 2021-10-15 00:00:58 +00:00
Casey Rodarmor
39301e9f8b
Remove deprecated equals error (#985) 2021-10-02 01:37:28 +00:00
Casey Rodarmor
0db4589efe
Implement regular expression match conditionals (#970) 2021-09-16 23:45:56 +00:00
Casey Rodarmor
09af9bb5e5
Change MSRV to 1.46.0 (#968) 2021-09-16 14:51:45 +00:00
Casey Rodarmor
629c75ff04
Use stable rustfmt instead of nightly (#967) 2021-09-16 13:44:40 +00:00
Casey Rodarmor
9ee1a63e99
Deduplicate recipe parsing (#923) 2021-07-28 05:51:46 +00:00
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
Casey Rodarmor
98457c05d7
Rename: Module → Ast (#915) 2021-07-24 03:26:27 +00:00
Casey Rodarmor
77bba3ee0e
Add subsequent dependencies (#820)
Subsequents are dependencies which run after a recipe instead of prior.
Subsequents to a recipe only run if the recipe succeeds. Subsequents
will run even if a matching invocation already ran as a prior
dependencies.
2021-07-22 00:20:25 -07:00
Casey Rodarmor
c76805ab9e
Implement else if chaining (#910) 2021-07-20 01:21:46 +00:00
Oleksii Dorozhkin
8677492d56
Add --fmt subcommand (#837) 2021-06-08 01:01:27 -07:00
Casey Rodarmor
7bc9d3986e
Fix bang lexing and placate clippy (#821) 2021-05-07 00:14:38 -07:00
Casey Rodarmor
67bd318bf9
Add positional-arguments setting (#804)
Allow recipe arguments to be passed as positional arguments to commands.
2021-04-24 18:29:58 -07:00
Casey Rodarmor
fec979c2c6
Reform and improve string literals (#793)
- Combine and simplify string and backtick lexing.
- Allow newlines in strings and backticks.
- Add triple-delimited indented strings and backticks. Common indented literal non-blank line leading whitespace is stripped.
- If a literal newline is escaped, it will be suppressed.
- Backticks starting with `#!` are reserved for a future upgrade.
2021-04-05 21:28:37 -07:00
Casey Rodarmor
dd578d141c
Unify string lexing (#790)
Unify lexing of backticks, cooked strings, and raw strings. Also allow
newlines in backticks and cooked strings, since I can't think of a reason
not to.
2021-04-04 16:41:02 -07:00
Casey Rodarmor
10282bd636
Turn = deprecation warning into a hard error (#780)
It's been around two and a half years, and many versions, since this
warning was first introduced, so it feels reasonable to finally turn it
into a hard error. It will remain a special-cased error for a little
while.
2021-03-28 23:39:23 -07:00
Casey Rodarmor
18b9799e8d
Add dotenv-load setting (#778)
The `dotenv-load` setting controls whether or not a `.env` file will be
loaded if present. It currently defaults to true.
2021-03-28 22:38:07 -07:00
Casey Rodarmor
6f42c8b737
Prefix parameters with $ to export to environment (#773)
If a parameter is prefixed with an `$`, it will be exported as an
environment variable.
2021-03-25 18:35:24 -07:00
Casey Rodarmor
b66a979c08
Add set export to export all variables as environment variables (#767)
Add a setting that exports all variables by default, regardless of
whether they use the `export` keyword. This includes assignments as well
as parameters.

Just does dependency analysis of variable uses, allowing variables to be
used out of order in assignments, as long as there are no circular
dependencies.

However, use of environment variable is not known to Just, so exported
variables are only exported to child scopes, to avoid ordering dependencies,
since dependency analysis cannot be done.
2021-03-25 17:00:32 -07:00
Casey Rodarmor
7ae890ce61
Note shebang line splitting inconsistency in readme (#757) 2021-02-15 01:18:31 -08:00
Casey Rodarmor
19f7ad09a7
Add conditional expressions (#714)
Add conditional expressions of the form:

   foo := if lhs == rhs { then } else { otherwise }

`lhs`, `rhs`, `then`, and `otherwise` are all arbitrary expressions, and
can recursively include other conditionals. Conditionals short-circuit,
so the branch not taken isn't evaluated.

It is also possible to test for inequality with `==`.
2020-10-26 18:16:42 -07:00
Casey Rodarmor
3643a0dff0
Add Parser::forbid (#712) 2020-10-25 23:57:08 -07:00
Casey Rodarmor
bdf1c92251
Automatically track expected tokens while parsing (#711)
Remove all manual tracking of which tokens would have been accepted by
the parser in favor of having the parser add tokens that it checks for
to a set of expected tokens, clearing them when it accepts a token, and
using the current contents of the set in error messages.

This is a massive improvement, and will make the parser easier to
modify going forward.

And, this actually solves my sole issue with hand-written parsers.

Thanks to matklad on reddit for suggesting this!
2020-10-25 19:37:26 -07:00
Richard Berry
1ff619295c
Add variadic parameters that accept zero or more arguments (#645)
Add "star" variadic parameters that accept zero or more arguments,
distinguished with a `*` in front of the parameter name.
2020-06-13 01:49:13 -07:00
Casey Rodarmor
9731278d2a
Wrap comments at 80 characters (#593)
I think 70 is too agressive, especially since it includes indentation
when determining line length.
2020-02-14 04:49:25 -08:00
Casey Rodarmor
3ec7dea4a3
Use unstable rustfmt configuration options (#592) 2020-02-10 20:07:06 -08:00
Casey Rodarmor
0931fa8dbf
Allow passing arguments to dependencies (#555)
Allow recipes that take parameters to be used as dependencies.
2019-12-07 04:03:03 -08:00
Casey Rodarmor
2d3134a91c
Reform scope and binding (#556)
Clean up scope handling by introducing `Binding` and `Scope` objects.
2019-12-07 03:09:21 -08:00
Casey Rodarmor
d2decbfdb8
Resolve functions (#550)
Modifies parsing to return strongly-typed `Thunk`s, which contain both
the function implementation, as well as the correct number of arguments.

This moves unknown function and function argument count mismatch errors
to parse time.
2019-11-21 12:14:10 -06:00
Casey Rodarmor
4f08bb4d77
Resolve alias targets (#548)
During analysis, resolve alias targets from `Name`s to `Rc<Recipe>`,
giving us type-level assurance that alias resolution was performed, and
avoiding the need to look up alias targets in a separate table when
running.
2019-11-21 09:39:32 -06:00
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
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
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
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
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
415c84ea39
Refactor and rename test macros (#415) 2019-04-19 02:17:43 -07:00
Casey Rodarmor
0ad5574ecc
Deprecate = in assignments, aliases, and exports in favor of := (#413) 2019-04-18 11:48:02 -07:00
Casey Rodarmor
eb3ae2d093
Replace some calls to brev crate (#410) 2019-04-16 22:06:28 -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
fe0a6c252c
Allow arbitrary expressions as default arguments (#400) 2019-04-11 23:58:08 -07:00
Casey Rodarmor
e118051a5c
Omit aliases that begin with _ from --list` (#398) 2019-04-11 15:57:34 -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