Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor rune-cli to be more command oriented #223

Merged
merged 6 commits into from
Dec 15, 2020

Conversation

tgolsson
Copy link
Contributor

This PR changes rune (rune-cli) to be based around commands and feel a bit more like cargo.

In this PR there is now three commands for Rune:

  • check: only compiles, emites all errors and warnings
  • test: runs all tests
  • run: runs the main entrypoint

Furthermore, there is now auto-find for the entrypoint as well, looking for main.rn, lib.rn, as well as in the subfolders src and script. This was necessary as one would otherwise have to make "path" part of every subcommand, which makes everything more complicated while being less ergonomic and needing more typing. The old mode is still possible by passing paths before the command.

Sample output:


➜ ../rune/target/debug/rune check
Checking: script/main.rn
// snip a ton of badly formatted warnings

➜ ../rune/target/debug/rune test
Found 23 tests...
Test day1::test_part1               passed
Test day1::test_part2               passed
Test day2::test_part1               passed
Test day2::test_part2               passed
Test day3::test_part1               passed
Test day3::test_part2               passed
Test day8::test_part1               passed
Test day8::test_part2               passed
Test day9::part2                    passed
Test day9::part1                    passed
Test day10::test_part1              passed
Test day10::test_part2              passed
Test day12::test_part1              passed
Test day12::test_part2              passed
Test day12::test_part2_rots         passed
Test day12::test_part2_ss           passed
Test day11::test_part1              passed
Test day11::test_part2              passed
Test day13::test_part1              passed
Test day13::test_part2              passed
Test day14::test_part1              passed
Test day14::test_part2              passed
Test day14::test_parse              passed
====
Executed 23 tests with 0 failures (0 skipped) in 0.308 seconds

➜ ../rune/target/debug/rune --color=always test -q
Found 23 tests...
.......................
====
Executed 23 tests with 0 failures (0 skipped) in 0.308 seconds

➜ ../rune/target/debug/rune run
== () (5.130348676s)

@tgolsson tgolsson added documentation Improvements or additions to documentation enhancement New feature or request rust-likeness Issues related to making Rune more like Rust through feature parity. labels Dec 15, 2020
@tgolsson tgolsson requested a review from udoprog December 15, 2020 08:25
@udoprog
Copy link
Collaborator

udoprog commented Dec 15, 2020

Added a few things:

  • Added SharedArgs, so that paths can be specified inside of each subcommand.
  • Cleaned up context and options construction a bit, since they should be done the same everywhere and fully depend on the args.
  • Modified the book to use the new run subcommand (hopefully didn't miss anything).

Copy link
Collaborator

@udoprog udoprog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming you're OK with my changes, feel free to merge.


let mut options = rune::Options::default();
const SPECIAL_FILES: &[&str] = &[
Copy link
Collaborator

@udoprog udoprog Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only part I'm a little bit skeptical over right now. All the entrypoints seem like potentially surprising, and they depend on where the command is executed rather than a well-defined project root.

I'm fine with keeping them for now though (maybe consider trimming) and superseding them with a more explicit mechanism in the future.

@udoprog
Copy link
Collaborator

udoprog commented Dec 15, 2020

Thanks for the overhaul!

It was a bit awkward to specify the paths before the subcommand, so I collapsed them into a SharedArgs which is flattened into each relevant subcommand instead.

@udoprog udoprog merged commit f2ad2ea into rune-rs:main Dec 15, 2020
@udoprog udoprog added the changelog Issue has been added to the changelog label Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Issue has been added to the changelog documentation Improvements or additions to documentation enhancement New feature or request rust-likeness Issues related to making Rune more like Rust through feature parity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants