Skip to content
This repository has been archived by the owner on Aug 23, 2018. It is now read-only.

Feature Proposoal: Format Flag for JS vs HTML output #177

Open
maxsnew opened this issue Aug 15, 2017 · 2 comments
Open

Feature Proposoal: Format Flag for JS vs HTML output #177

maxsnew opened this issue Aug 15, 2017 · 2 comments
Labels

Comments

@maxsnew
Copy link

maxsnew commented Aug 15, 2017

Motivation

As a build tool for a web technology, elm-make is not just used directly by humans but also by build scripts that combine elm with programs written in other languages.
The current interface is optimized for direct human interaction, which is a fine default but should be overridable for unforeseen use-cases.
Specifically, elm make Main.elm --output=main.js parses the filename given in the --output option, meaning tools can't output to files that do not end in js or html.

Proposal: --format Flag

My proposal is to add a --format flag that would allow you to ignore the filename and declare the intended output format directly.
Currently you would have 2 options: js,html but we can easily add more in the future if needed.

# write js output to main.js
> elm make Main.elm --output=main.js
# writes js output to main
> elm make Main.elm --format=js --output=main
# write js output to main.html
> elm make Main.elm --format=js --output=main.html

This change would be backwards-compatible and wouldn't affect any user not using the feature except in that it makes elm make -h longer.

Use Case: Output to stdout

One non-obvious side effect of this would be to partially solve #39 at least on unix-like systems using /dev/stdout as a filename:

# prints js compilation to stdout
> elm make Main.elm --format=js --output=/dev/stdout

so this would make elm make much easier to use for scripting for the reasons lain out in that issue.
I don't know enough about Windows to say for sure, but from some brief googling it looks like this would not solve #39 for them.

@process-bot
Copy link

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@maxsnew
Copy link
Author

maxsnew commented Aug 17, 2017

In implementing this change and trying it out I now see that printing to /dev/stdout would only really work if we add a --silent option that suppresses other printing to stdout.

Looking into that, I see that this would require some changes to elm-package.

@evancz evancz added the request label Mar 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants