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

Add support to read from stdin for the juvix format command #2008

Closed
jonaprieto opened this issue Apr 14, 2023 · 0 comments · Fixed by #2028
Closed

Add support to read from stdin for the juvix format command #2008

jonaprieto opened this issue Apr 14, 2023 · 0 comments · Fixed by #2028
Assignees
Labels
Milestone

Comments

@jonaprieto
Copy link
Collaborator

jonaprieto commented Apr 14, 2023

At present, the juvix format requires a file path or a directory as input for formatting Juvix code. The primary motivation behind this option is to substitute the dev scope call in the VSCode extension, enabling us to invoke the format command more flexibly and read directly from stdin. Also, notice that this flag --stdin is offered as global, so one really expects this works.

@jonaprieto jonaprieto added the CLI label Apr 14, 2023
@jonaprieto jonaprieto added this to the 0.3.2 milestone Apr 14, 2023
@jonaprieto jonaprieto modified the milestones: 0.3.2 - HB-J, 0.3.3 Apr 18, 2023
jonaprieto pushed a commit that referenced this issue Apr 21, 2023
* Exploration of #2008 

As I were trying to fix the behaviour of `format` command with the
`--stdin` global option, I noticed that actually it is already behaves
the same was as `dev scope` command (which was the desire at least at
this point).

So, no actual behaviour of the command is channged, only a few tests
added to showcase some edge cases of the command with the `--stdin`
option together.

Here are the highlights:

* The filename is **not** optional for both `dev scope` and `format`
even if with `stdin` the content of the file comes from the input.
* `format` command expects the stdin input to be a proper module
* the name of the stdin module should be aligned with the provided
filename even though its sources are not used

I think that some of the above behaviours we can consider to change. Let
me know what do you think about any of that.

Otherwise, the `dev scope` command can be replaced with `format`.
jonaprieto pushed a commit that referenced this issue Apr 27, 2023
# Description

No the filepath in the `juvix forma` command is n=made optional.
However, in that case, the `--stdin` command is required.

### Implementation details

~For now, as a quick solution, I have introduce the "fake" path that is
used for `fomat` command with stdin option.~
I needed to do a couple of big changes:
* `format` command FILE is now optional, howvere, I check that in case
of `Nothing` `--stdin` option should be present, otherwise it will fail
 * `entryPointModulePaths` is now `[]` instead of `NonEmpty`
* `ScopeEff` now has `ScopeStdin` constructor as well, which would take
the input from stdin instead of having path passed around
* `RunPipelineNoFileEither` is added to the `App` with the bunch of
`*Stdin` functions that doesn't require filepath argument to be passed

Fixes #2008

## Type of change

- [x] New feature (non-breaking change which adds functionality)

# Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works:
  - [x] smoke tests

---------

Co-authored-by: Paul Cadman <git@paulcadman.dev>
Co-authored-by: janmasrovira <janmasrovira@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants