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

Move the CLI into its own crate #1351

Merged
merged 13 commits into from
Jun 16, 2023
Merged

Move the CLI into its own crate #1351

merged 13 commits into from
Jun 16, 2023

Conversation

vkleen
Copy link
Contributor

@vkleen vkleen commented Jun 9, 2023

Move the Nickel CLI into its own crate nickel-lang-cli. This will make it easier to integrate external tools such as Topiary without incurring a ton of dependencies in the nickel-lang crate.

In the future, we may want to split out the REPL handling from nickel-lang into the CLI, and the WASM interface. But for now, this PR is just a straightforward move.

@vkleen vkleen requested a review from yannham June 9, 2023 12:09
@github-actions github-actions bot temporarily deployed to pull request June 9, 2023 12:13 Inactive
Copy link
Member

@yannham yannham left a comment

Choose a reason for hiding this comment

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

I think there several things to consider. How that will play with the next update? For example, people updating the nickel-lang package via cargo, thinking they will just have the latest version of the binary, will find an error saying something like "there's no binary available" I guess? I wonder how we could smooth the transition.

Second, It's not horrible but it's a bit sad to split the test in two (mainly because the source code controlling error messages are not in the CLI crate currently, but thinking about it, maybe they should just be? I don't really know the answer at this point)

cli/Cargo.toml Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pull request June 9, 2023 16:01 Inactive
@vkleen
Copy link
Contributor Author

vkleen commented Jun 9, 2023

The error message formatting itself should probably stay accessible from the nickel-lang crate. For example, the Python bindings report an error message as a string and I'd expect people embedding Nickel wouldn't want to reimplement the formatting for errors every time. But splitting the tests is a bit sad. I think the problem is that there are really two interwoven components that the snapshot tests are testing. One is the CLI interface with export, etc., and their interaction with pretty printing and error reporting; an end-to-end integration test in a way. The other component is the error message printing itself and the format of the error messages.

I suppose we could split the snapshot tests by purpose, but I'm not sure the effort would be worth it at the moment.

Copy link
Member

@yannham yannham left a comment

Choose a reason for hiding this comment

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

I wonder also if we shouldn't move everything ito its own subdirectory, including the nickel-lang crate, and name directories accordingly, so that the hierarchy is more consistent. Also, we might have to update the README or other documentation lying around about running tests, since there's now tests located inside two different crates.

@vkleen
Copy link
Contributor Author

vkleen commented Jun 13, 2023

I like the idea of nickel-lang living in its own subdirectory as well. The last commit does that and fixes the associated test failures. I'll have a look at the READMEs next.

@github-actions github-actions bot temporarily deployed to pull request June 13, 2023 13:23 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 13, 2023 14:03 Inactive
@vkleen vkleen force-pushed the separate-cli-crate branch from 06bc9f8 to be1bc6b Compare June 13, 2023 15:39
@github-actions github-actions bot temporarily deployed to pull request June 13, 2023 15:43 Inactive
@vkleen vkleen requested a review from yannham June 14, 2023 08:51
@github-actions github-actions bot temporarily deployed to pull request June 14, 2023 08:54 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 14, 2023 14:03 Inactive
@vkleen vkleen force-pushed the separate-cli-crate branch from b08dd47 to 38b4ff4 Compare June 14, 2023 15:35
@github-actions github-actions bot temporarily deployed to pull request June 14, 2023 15:39 Inactive
@vkleen vkleen force-pushed the separate-cli-crate branch from 38b4ff4 to 47b4b1c Compare June 15, 2023 08:07
@github-actions github-actions bot temporarily deployed to pull request June 15, 2023 08:12 Inactive
@yannham
Copy link
Member

yannham commented Jun 15, 2023

@vkleen is it ready for review? Last time I checked there were still some mixed up stuff with nickel-lang, nickel-lang-cli and nickel-lang-lib

@vkleen
Copy link
Contributor Author

vkleen commented Jun 15, 2023

I think it's ready for review now. Hopefully I've found all the mixups 😅

@vkleen vkleen force-pushed the separate-cli-crate branch from 47b4b1c to 2261cc0 Compare June 15, 2023 14:15
@github-actions github-actions bot temporarily deployed to pull request June 15, 2023 14:19 Inactive
@vkleen vkleen force-pushed the separate-cli-crate branch from 2261cc0 to 8caab69 Compare June 15, 2023 15:07
@github-actions github-actions bot temporarily deployed to pull request June 15, 2023 15:11 Inactive
@vkleen vkleen force-pushed the separate-cli-crate branch from 8caab69 to 451ec86 Compare June 16, 2023 11:52
@github-actions github-actions bot temporarily deployed to pull request June 16, 2023 11:56 Inactive
Copy link
Member

@yannham yannham left a comment

Choose a reason for hiding this comment

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

I'm still not 100% sure about the nickel-lang vs nickel-lang-cli 😅 but I guess if we want to change that for the next release, it's just a small search and replace, isn't it? It's better to proceed with the new file hierarchy to avoid painful rebasing.

HACKING.md Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
- `nickel-lang-lsp` (path: `lsp/nls/`). the Nickel Language Server (NLS), an LSP
- `nickel-lang-lib` (path: `nickel-lang-lib`). The main crate containing the interpreter
as a library.
- `nickel-lang` (path: `nickel-lang-cli`). The `nickel` binary.
Copy link
Member

Choose a reason for hiding this comment

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

Ah, so the path is nickel-lang-cli, but the crate name will be nickel-lang ? Hmm...that sounds a bit confusing. On the other hand, I agree that nickel-lang is a bit misleading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At some point, I had the CLI just under cli, like the utilities subdirectory now. I don't think there's any paritcular necessity to tie the directory name to the crate name, and just nickel-lang felt a bit misleading as you say.

flake.nix Show resolved Hide resolved
utilities/src/project_root.rs Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pull request June 16, 2023 13:39 Inactive
@vkleen
Copy link
Contributor Author

vkleen commented Jun 16, 2023

I'm still not 100% sure about the nickel-lang vs nickel-lang-cli sweat_smile but I guess if we want to change that for the next release, it's just a small search and replace, isn't it? It's better to proceed with the new file hierarchy to avoid painful rebasing.

It's not quite a search and replace, but we're not using the string "nickel-lang" in all too many places, so it's not very painful. I agree that it's better to proceed as is and switch the names around later if we feel like it.

@github-actions github-actions bot temporarily deployed to pull request June 16, 2023 13:51 Inactive
@vkleen vkleen added this pull request to the merge queue Jun 16, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 16, 2023
@vkleen vkleen enabled auto-merge June 16, 2023 15:52
@vkleen vkleen force-pushed the separate-cli-crate branch from 2cd7550 to 6aa84e9 Compare June 16, 2023 15:54
@github-actions github-actions bot temporarily deployed to pull request June 16, 2023 16:00 Inactive
@vkleen vkleen disabled auto-merge June 16, 2023 16:03
@vkleen vkleen enabled auto-merge June 16, 2023 16:03
@vkleen vkleen added this pull request to the merge queue Jun 16, 2023
Merged via the queue into master with commit 3e03cc7 Jun 16, 2023
@vkleen vkleen deleted the separate-cli-crate branch June 16, 2023 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants