Commit Graph

234 Commits

Author SHA1 Message Date
Casey Rodarmor
afe2c0f94e
Refactor more tests into macro invocations (#259) 2017-11-18 01:44:59 -08:00
Casey Rodarmor
28a57d9828
Refactor evaluators and resolvers into common form (#258) 2017-11-18 01:18:04 -08:00
Casey Rodarmor
bc79d16eac
Convert parser tests to macros (#257) 2017-11-17 23:59:55 -08:00
Casey Rodarmor
87b2130db0
Use imperative mood in help strings (#256) 2017-11-17 23:59:36 -08:00
Casey Rodarmor
c84a86dd2b
Use uppercase names for arguments (#255) 2017-11-17 23:23:24 -08:00
Casey Rodarmor
7166fa9e6f
Rename options to configuration (#254) 2017-11-17 23:23:02 -08:00
Travis snɯǝᗡɔW
acb5d6f98b Do not evaluate backticks in assignments during dry runs (#253) 2017-11-17 20:21:37 -08:00
Casey Rodarmor
13a124d659
Refactor some other stuff (#252) 2017-11-17 17:28:06 -08:00
Casey Rodarmor
2b6b715528
Refactor Everything (#250) 2017-11-16 23:30:08 -08:00
Casey Rodarmor
86dc82f548
Give errors clearer names (#249) 2017-11-16 13:26:01 -08:00
Casey Rodarmor
3acd56646f
Stop empty comments from swallowing the next line (#247) 2017-11-15 12:53:01 -08:00
Casey Rodarmor
b9e1f73919
Make unexpected token formatting clearer (#243)
Symbols are now be surrounded by single quotes, to set them off more
clearly.
2017-11-14 13:03:26 -08:00
Casey Rodarmor
6e3b43ac9e Overhaul README (#231)
- Switch to asciidoc, since it supports an auto-generated table of contents
- Re-organize into sections
- Document private recipes
- Document windows dependencies
- Document doc comments
2017-10-12 16:12:23 -07:00
Casey Rodarmor
8fa91a4eb1 Hide recipes with names starting with an _ from --list and --sumamary (#229) 2017-10-06 23:48:07 -07:00
Christopher Vittal
a07fc226c1 Add short options for justfile and working-directory (#222)
Adds -f and -d as short options for --justfile and --working-directory
respectively.

Thanks @chrisvittal!
2017-09-11 00:58:35 -07:00
Casey Rodarmor
e22da124d4 Update dependencies (#225)
Thanks @chrisvittal for reporting!
2017-09-10 17:28:00 -07:00
Casey Rodarmor
58f545f240 🔥 Stop parsing flags after positional args (#219)
This allows things like the following to work as,
I hope, one would expect:

  commit +flags:
    git commit {{flags}}

  $ just commit -a

It is however a breaking change, so also bump version number to 0.3.0.
2017-08-18 14:21:18 -07:00
Casey Rodarmor
1fd1c05653 Retire warn! in favor of eprintln! (#218) 2017-08-18 14:15:43 -07:00
Casey Rodarmor
4320d1c699 Remove integration test debug spam (#206) 2017-06-03 22:46:07 -07:00
Casey Rodarmor
1b1a155dda Refactor color handling (#204)
Color logic is fairly complicated, so moved it into its own
module.

A `Color` object now encapsulates the --color setting, which
stream we are printing to, and what color we are painting.

This way, Color::paint can just do the right thing when asked to
paint text.

Also added tests to make sure that --list and --highlight colors
are using the correct color codes.
2017-06-01 18:01:35 -07:00
Casey Rodarmor
98fe09f26b Fix lints and things that make clippy sad (#199) 2017-05-12 22:09:47 -04:00
Casey Rodarmor
839f314439 Make appveyor continuous integration tests pass (#196) 2017-05-12 22:03:43 -04:00
Casey Rodarmor
59d863f6f4 Use crate metadata in --help string (#197) 2017-05-09 20:31:30 -04:00
Casey Rodarmor
b84fa89d71 Remove debugging output (#195) 2017-05-07 23:27:52 -04:00
Casey Rodarmor
4a35c14024 Set up cross platform continuous integration on travis (#191)
Gets travis cross platform testing working.

Based on the templates from:

japaric/trust/commit/29b0e084ff2c40d1aa1b6a5d66ab81eca90439e1
2017-05-07 22:48:07 -04:00
Casey Rodarmor
616d324cd7 Error if running default recipe that requires arguments (#194) 2017-05-07 15:11:10 -07:00
Casey Rodarmor
200cb4ee26 Add period to empty justfile error message (#192) 2017-05-07 14:50:46 -07:00
Casey Rodarmor
7f2d360231 Write argument_range() in terms of min_arguments() and max_arguments() (#193) 2017-05-07 14:45:23 -07:00
Casey Rodarmor
1990c58a21 Add option to highlight echoed recipe lines (#190)
Using bold and cyan, for visibility.
2017-04-25 23:39:34 -07:00
Casey Rodarmor
bb15310549 Unicode integration test fix for windows (#189)
Windows had trouble with a backtick, so simplify it
2017-04-23 16:36:38 -07:00
Casey Rodarmor
165e7951af Use cygpath to translate paths on windows (#188)
I was previous doing it manually, which failed when running in
powershell in a Github Desktop for windows.

Use the `cygpath` utility instead.
2017-04-23 16:09:34 -07:00
Casey Rodarmor
832cf7b357 Move output() and OutputError into brev (#187)
They're pretty generic and generally useful, so move them into brev on crates.io.
2017-04-23 15:37:17 -07:00
Casey Rodarmor
af764f5eab Refactor RunError::Backtick* to use OutputError (#186)
Add `output()` to get stdout of a command, return a OutputError if
it failes. Refactor backtick run errors to contain an OutputError.
2017-04-23 14:21:21 -07:00
Casey Rodarmor
84a55da1ce Make shebangs work on windows (#185)
We use EXEPATH, which points to the root of the MinGW installation
and can be used as a base for translating the unix path to the
executable in the shebang line.

If we're not on MinGW, well, we just throw up our hands and hope
for the best.
2017-04-22 21:39:29 -07:00
Casey Rodarmor
6a0e3abb32 Improve shebang execution error message (#184)
I was reusing TmpdirIoError for a few cases, but one of them
usually has more to do with the contents of the shebang line than
an actual io error involving the tmpdir. Pull it out into its own
RunError variant and improve the message.
2017-04-22 19:05:51 -07:00
Casey Rodarmor
a6e1cc8ac5 Uppercase integration test exported variable names (#183)
For windows, since windows environment variables are not case
sensitive.
2017-04-22 16:39:13 -07:00
Casey Rodarmor
8d1ef2f54f Fix type in unit test panic message (#182) 2017-04-22 16:22:54 -07:00
Casey Rodarmor
b0c5fa23ee Multi shell integration tests (#181)
* Run integration tests on multiple shells

To make sure that I don't break tests for shells other than my
dev-box's `sh` and the `sh` on travis, each integration test case
now runs using `sh`, `dash`, and `bash.
2017-04-22 16:15:15 -07:00
Casey Rodarmor
2b294f0b30 Create platform module (#178)
Moves platform specific functionality into its own module.

Thanks to @Meralis40 for starting this!

This also gets just building on windows \^_^/

Although a lot of tests still fail (✖╭╮✖)

The `PlatformInterface` trait contains functions which abstract
over platform specific functionality, with implementations for
different platforms behind #[cfg(*)] attributes.

- `make_shebang_command()` constructs a command which will execute
  the given script as if by a shebang. On linux this executes the
  file, on windows it runs the interpreter directly.

- `set_execute_permission()` sets the execute permission on a
  file. This is a nop on windows, since all files are executable.

- `signal_from_exit_status()` extracts the signal a process was
  halted by from its exit status, if it was halted by a signal.
2017-04-21 22:20:13 -07:00
Casey Rodarmor
6a26c72131 Use libc::{EXIT_SUCCESS, EXIT_FAILURE} for status (#177) 2017-04-21 22:11:18 -07:00
Casey Rodarmor
f38f984f12 Use CAPITALIZED option names (#176)
Since this seems to be the convention.
2017-04-20 23:24:23 -07:00
Casey Rodarmor
c9ce4601b9 Add --shell option to specify the shell to use (#175)
Mostly for debugging purposes, so I can make sure behavior is
consistent across different shells. Although I suppose this might
also be of use if you've got a mega weird `sh` that you'd like to
avoid.

Defaults to `sh` so current behavior is preserved.
2017-04-20 23:06:03 -07:00
Casey Rodarmor
799986dd34 Sort clap arguments alphabetically (#174) 2017-04-20 22:49:51 -07:00
Casey Rodarmor
d7bb94ab5b Update and adapt to latest versions of dependencies (#171)
- Unicode 9 defines emoji to be wide characters; before their
  width was ambiguous. unicode-width has picked this up, so the
  tests which expected emoji to be single-width have been updated.

- The ordering of the --quiet and --dry-run flags seems to be
  have flipped in a clap error message, which broke a test, which
  is unbroken by this commit
2017-04-20 21:38:44 -07:00
Casey Rodarmor
435b4c5ea3 Remove trailing whitespace (#167) 2017-04-02 20:39:23 -07:00
Casey Rodarmor
b6b01bf6d4 🔥 Disallow names that start with '-' (#154)
This is done for two reasons:

1. Such names cannot be given on the command line, since clap will
intercept them and wrongly interpret them as flags.

2. The name '---' can conflict with yaml document delimiters. Kind of
speculative, but I was thinking that it would be nice to make sure that
'---' and '...' are illegal in a justfile, so that that one can be
included in a yaml document stream. Is this silly? I am really not sure.

This is backwards incompatible, but I don't think anyone will notice,
since names that start with '-' are likely to be rare.
2017-02-10 20:15:25 -08:00
Casey Rodarmor
bed28c1df5 Resolve dependencies after the first (#149)
The recipe dependency resolver had a bug which caused it to not resolve
dependencies after the first.

This caused the parameter check later in the program to crash.

Added a test and fixed it.

Fixes #148.
2017-01-18 20:32:55 -08:00
Casey Rodarmor
1befc8674e Test all errors and error messages (#145) 2017-01-08 19:01:48 -08:00
Casey Rodarmor
64e4905e49 Capitalize all error messages (#144) 2017-01-08 17:26:34 -08:00
Casey Rodarmor
d17911a573 Use '/' instead of "/" as argument to rfind (#141) 2016-12-30 00:23:32 -08:00
Casey Rodarmor
b267d0444e Allow path-prefixed first arguments (#139)
If the first argument to just contains a `/`, then it will be handled
specially. Everything before the last `/` is treated as a directory, and
just will search for the justfile starting there, instead of in the
current directory.
2016-12-30 00:09:35 -08:00
Casey Rodarmor
c6256333ed Lift limitations on recipes that take parameters (#137)
Previously, only one recipe with parameters could be passed on the
command line. This was to avoid confusion in case the number of
parameters a recipe took changed, and wound up using as an argument was
was once a recipe.

However, I don't think this is actually particularly confusing in
practice, and could be a slightly annoying limitation.

Now, any number of recipes with parameters may be given on the command
line.

Fixes #70
2016-12-10 16:35:52 -08:00
Casey Rodarmor
af543d7258 Remove duplicate return (#136) 2016-12-10 16:31:38 -08:00
Casey Rodarmor
11c0d349db Collapse unnecessary block (#128) 2016-11-18 07:07:20 -08:00
Casey Rodarmor
1ac5b4ea42 Add variadic parameters (#127)
Recipes may now have a final variadic parameter:

```make
foo bar+:
  @echo {{bar}}
```

Variadic parameters accept one or more arguments, and expand to a string containing those arguments separated by spaces:

```sh
$ just foo a b c d e
a b c d e
```

I elected to accept one or more arguments instead of zero or more arguments since unexpectedly empty arguments can sometimes be dangerous. 

```make
clean dir:
  rm -rf {{dir}}/bin
```

If `dir` is empty in the above recipe, you'll delete `/bin`, which is probably not what was intended.
2016-11-18 07:03:34 -08:00
Casey Rodarmor
cef117f8bd Report line number in recipe failure messages (#125)
The grammar now permits blank lines in recipes.

Note that inside of recipes, the token `NEWLINE` is used instead of the
non-terminal `eol`. This is because an `eol` optionally includes a
comment, whereas inside recipes bodies comments get no special
treatment.
2016-11-16 22:18:55 -08:00
Casey Rodarmor
07634d9390 Fix line numbers (#124)
Blank lines were being ignored by the parser, so lines would be reported
incorrectly in error messages from shebang recipes. Blank lines are now
included by the parser, so shebang recipes expand to have the non-blank
lines in the expected place in the file.
2016-11-16 21:37:43 -08:00
Casey Rodarmor
2f4bcc57bc Add --verbose flag (#123)
Causes all recipe lines to be printed, regardless of --quiet or `@`.
Prints the name of each recipe before running it. Hopefully useful for
diagnosing problems.
2016-11-16 21:06:51 -08:00
Casey Rodarmor
133b4a2ada Renames: Parser::file and just::parse (#122)
Parser::file -> Parser::justfile
just::parse -> just::compile

Also get rid of super::, super::std
2016-11-16 20:17:24 -08:00
Casey Rodarmor
e628378dbb Avoid using panic! outside of tests (#121)
Don't panic.
2016-11-15 20:39:56 -08:00
Casey Rodarmor
91d1e59667 Fix override argument processing bug (#115)
An invocation like `just foo=bar` would lead to no recipe being run due
to the way that override arguments were being processed.

Fix that and add a test that covers that case.
2016-11-13 21:26:28 -08:00
Casey Rodarmor
10c377b88c Allow ' raw strings to contain literal newlines (#107)
Fixes #8
2016-11-13 14:04:20 -08:00
Casey Rodarmor
2b81dc2b76 Fix spurious circular dependency error (#102)
The resolver.seen() needs to be cleared between recipes.

Also add push recipe for creating branches on github without needing to
create one locally.
2016-11-13 00:01:42 -08:00
Casey Rodarmor
26bfef4a2f Add doc comments to recipes (#101)
If a `#...` comment appears on the line immediately before a recipe, it
is considered to be a doc comment for that recipe.

Doc comments will be printed when recipes are `--list`ed or `--dump`ed.

Also adds some color to the `--list`ing.

Fixes #84
2016-11-12 23:31:19 -08:00
Casey Rodarmor
112462ec62 Toggle meaning of '@' on recipes prefixed with '@' (#100)
Fixes #65
2016-11-12 16:12:00 -08:00
Casey Rodarmor
babe97bf0d Allow line continuations in plain recipes with '\' (#99)
Some ugly code, but not as bad as I thought.

Elected not to go with indentation based line continuations. Too many
weird edge cases and feels like a gratuitious incompatibility with make.

Fixes #9
2016-11-12 15:45:12 -08:00
Casey Rodarmor
5b2d671c1d Get rid of mostly unused Justfile.recipes() (#98) 2016-11-12 14:43:47 -08:00
Casey Rodarmor
1856646a9c Error -> CompileError (#97)
Fixes #43
2016-11-12 14:24:33 -08:00
Casey Rodarmor
caf2570bb2 Don't allow args with early exit options (#96)
Fixes #85
2016-11-12 14:04:46 -08:00
Casey Rodarmor
2f530adf48 Add -e/--edit option to open justfile in $EDITOR (#95) 2016-11-12 14:02:15 -08:00
Casey Rodarmor
0dcdc5dc81 Use clap::ArgGroup for early exit conflicts (#94) 2016-11-12 13:31:54 -08:00
Casey Rodarmor
7cfc37f647 Line up names in --evaluate (#93)
Fixes #66
2016-11-12 13:12:43 -08:00
Casey Rodarmor
edbd94d654 Test that overrides are not evaluated (#92) 2016-11-12 13:03:33 -08:00
Casey Rodarmor
3d8d901968 Suggest alternatives to uknown recipes (#91)
Kind of silly, but why not. Will only suggest an alternative if edit
distance is less than 3. This could probably increase if the names are
longer.
2016-11-12 12:36:12 -08:00
Casey Rodarmor
6e8289c624 Make --list print recipes with arguments (#88)
Added `--summary` which just prints recipe names, like `--list` previous
to this change.

Fixes #75
2016-11-12 11:40:52 -08:00
Casey Rodarmor
5a5209fb5c Harmonize argument help text (#86)
Clap uses "Prints help information" for the help string, so change
verbs to match that.
2016-11-12 09:52:52 -08:00
Casey Rodarmor
7e3859ef18 Fix needless borrow clippy lints (#81) 2016-11-12 09:33:38 -08:00
Casey Rodarmor
95edb8ac3c Fix long lines (#80) 2016-11-12 09:28:30 -08:00
Casey Rodarmor
ff2ca9b30c Improve missing parameter panic message (#79)
Returning an InternalError in a map() is hard, so just panic, but give a
decent error message.
2016-11-12 09:24:52 -08:00
Casey Rodarmor
886acf2f95 Let recipes take default arguments (#77)
Looks like this:

```make
recipe argument default-argument='default value':
  echo argument is {{argument}}
  echo default-argument is {{default-argument}}
```

Thanks @deckarep for the feature request!

Fixes #49
2016-11-12 09:15:13 -08:00
Casey Rodarmor
5663cb61a6 Use ...? instead of try!(...) (#72)
See https://blog.rust-lang.org/2016/11/10/Rust-1.13.html for more info.

Huge diff, but all tests still pass, so yolo.
2016-11-11 21:37:16 -08:00
Casey Rodarmor
98990fe2ab Use clap's conflicts_with and requires (#68)
Seems better than writing it by hand.
2016-11-11 20:47:17 -08:00
Casey Rodarmor
0f9fb418a0 Add --dump option to print entire justfile (#67)
Already implemented Display for Justfile, so no reason not to expose it
to the user.

Also only allow one of --list, --dump, or --show, since they don't make
a lot of sense together.
2016-11-11 20:25:37 -08:00
Casey Rodarmor
510a269d00 Remove unnecessary lifetimes (#58)
Thanks clippy!
2016-11-11 19:12:44 -08:00
Casey Rodarmor
2882b78de5 Don't ignore --color=never (#56)
Fixes a bug where `--color=never` was ignored.
2016-11-11 18:46:04 -08:00
Casey Rodarmor
ac7634000e Fix error messages with wide character
Input may contain tabs and other characters whose byte widths do not
correspond to their display widths. This causes error context
underlining to be off when lines contain those characters

Fixed by properly accounting for the display width of characters, as
well as replacing tabs with spaces when printing error messages.
2016-11-11 17:32:35 -08:00
Casey Rodarmor
4d20ffeac4 Use colors in output
This is a pretty gross commit, since it also includes a lot of
unrelated refactoring, especially of how error messages are printed.

Also adds a lint recipe that prints lines over 100 characters

To test, I added a `--color=[auto|always|never]` option that defaults to
auto in normal use, but can be forced to `always` for testing. In `auto`
mode it defers to `atty` to figure out if the current stream is a
terminal and uses color if so.

Color printing is controlled by the `alternate` formatting flag.

When printing an error message, using `{:#}` will print it with colors
and `{}` will print it normally.
2016-11-11 17:32:35 -08:00
Casey Rodarmor
6b888bbfe4 Fix off by one error in backtick error message (#52)
I was using the width of the index of the line, not the displayed line
number, which is the index + 1, which could cause the error message to
be misaligned.

Fixed it, and added a test that checks for this.
2016-11-11 17:15:16 -08:00
Casey Rodarmor
74fa6d4962 Include line in all error messages (#51)
I had previously not included the line for some error messages, but I
don't think that I had a good reason why, and they look pretty good,
so adding them back for consistency.
2016-11-11 17:09:51 -08:00
Casey Rodarmor
2bc55ba815 Improve a few error messages (#47)
Surround variables with backticks, capitalize first letter of error
message, inflect properly depending on number of unknown overrides, and
improve wording.

Also added build dependency to `filter` recipe.
2016-11-11 14:33:17 -08:00
Casey Rodarmor
e3aa13e5dd Add integration tests for arguments (#42)
There were unit tests, but it seems like a good idea to test this end to end.
2016-11-11 13:34:28 -08:00
Casey Rodarmor
c775828d3c Use version from env! macro (#37)
This saves us from having to manually keep the version string in app.rs
up to date, so we can also drop that check from the publish recipe.

Fixes #36
2016-11-10 23:09:02 -08:00
Casey Rodarmor
2b55ae35bb Use colored help message (#32)
💙💜💚❤️💛
2016-11-07 21:05:07 -08:00
Casey Rodarmor
39a78c968f Bump version to 0.2.16 (#21) 2016-11-05 01:54:44 -07:00
Casey Rodarmor
9a742e6336 Allow justfile to be named Justfile (#19)
Priority is given to `justfile` to match the behavior of GNU make.
2016-11-05 01:25:36 -07:00
Casey Rodarmor
adef254b23 Avoid bashisms in tests (#18)
Since `sh` might be different depending on the system, avoid testing
status codes and error messages that are not the same across all `sh`s
2016-11-05 01:19:54 -07:00
Casey Rodarmor
e4d35a8270 Add --quiet/-q flag to supress all output (#17)
This is for avoiding writing to stderr during tests,
although it's a nice option so it feels worth exposing
to users.
2016-11-05 01:01:43 -07:00
Casey Rodarmor
599cc80f86 Move all run options into a struct (#16)
In preparation for adding a --quiet flag, since the number of parameters
to run is getting a bit silly.
2016-11-05 00:31:38 -07:00
Casey Rodarmor
dd16fe316b Bump version to v0.2.15 2016-11-02 22:06:52 -07:00
Casey Rodarmor
9f2568c461 Fix tab-indented lines in shebang recipes
Fixed a precedence bug in the recipe parser where tab-indented
lines in a shebang recipe would trigger an ExtraLeadingWhitespace
error.
2016-11-02 22:02:29 -07:00