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

[WIP] Introduce crystal --fake_source=sourcepath flag #4569

Conversation

akzhan
Copy link
Contributor

@akzhan akzhan commented Jun 14, 2017

to compile source from STDIN, closes #4561.

Synopsys

cat src/math/math.cr | ./bin/crystal build --no-codegen --no-color -o /dev/null -f json --fake-source src/math/math.cr

@@ -450,6 +450,9 @@ class Crystal::Command
end

private def gather_sources(filenames)
if ENV.has_key?("CRYSTAL_FAKE_SOURCE_FILENAME")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest getting rid of extra ENV#[] call, like:

if fake_source_filename = ENV["CRYSTAL_FAKE_SOURCE_FILENAME"]?
  return [Compiler::Source.new(fake_source_filename, STDIN.gets_to_end)]
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just reworked as --fake-source flag. looks cleaner.

@RX14
Copy link
Contributor

RX14 commented Jun 14, 2017

This seems like a weird solution. I don't mind CRYSTAL_FAKE_SOURCE_FILENAME but it shouldn't be required just to compile a file from stdin. The default should just be stdin as the filename with requires relative to the cwd.

@akzhan akzhan force-pushed the introduce-CRYSTAL_FAKE_SOURCE_FILENAME-env-var branch from 0926c89 to 0589534 Compare June 14, 2017 21:32
@akzhan akzhan changed the title Introduce ENV["CRYSTAL_FAKE_SOURCE_FILENAME"] to compile source from STDIN Introduce crystal --fake_source-sourcepath flag Jun 14, 2017
@akzhan akzhan changed the title Introduce crystal --fake_source-sourcepath flag [WIP] Introduce crystal --fake_source-sourcepath flag Jun 14, 2017
@akzhan
Copy link
Contributor Author

akzhan commented Jun 14, 2017

@RX14 Yes, it is just a proposal (how to implement). Now it is --fake-source compiler flag.

Feel free to rework.

@akzhan akzhan changed the title [WIP] Introduce crystal --fake_source-sourcepath flag [WIP] Introduce crystal --fake_source=sourcepath flag Jun 14, 2017
@akzhan akzhan force-pushed the introduce-CRYSTAL_FAKE_SOURCE_FILENAME-env-var branch from 4ef7d90 to 1bd3250 Compare June 14, 2017 22:32
@akzhan akzhan closed this Jun 14, 2017
@akzhan
Copy link
Contributor Author

akzhan commented Jun 14, 2017

Followed with #4571 with cleaner code.

@akzhan akzhan deleted the introduce-CRYSTAL_FAKE_SOURCE_FILENAME-env-var branch June 14, 2017 22:43
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.

Compile source from STDIN
3 participants