-
Notifications
You must be signed in to change notification settings - Fork 710
Add cabal scripting support #5483
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
Changes from all commits
0fbd845
e0d8291
b26a029
45834a5
049e157
e0b6f3c
92f0959
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,6 +419,29 @@ have to separate them with ``--``. | |
|
||
$ cabal new-run target -- -a -bcd --argument | ||
|
||
'new-run' also supports running script files that use a certain format. With | ||
a script that looks like: | ||
|
||
:: | ||
|
||
#!/usr/bin/env cabal | ||
{- cabal: | ||
build-depends: base ^>= 4.11 | ||
, shelly ^>= 1.8.1 | ||
-} | ||
|
||
main :: IO () | ||
main = do | ||
... | ||
|
||
It can either be executed like any other script, using ``cabal`` as an | ||
interpreter, or through this command: | ||
|
||
:: | ||
|
||
$ cabal new-run script.hs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please also add an example of how to pass command-line arguments to a script started with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's exactly right, I thought it was regular enough with the rest of |
||
$ cabal new-run script.hs -- --arg1 # args are passed like this | ||
|
||
cabal new-freeze | ||
---------------- | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably needs
default-language: Haskell2010
as well, since otherwise you always get a warning. Unless we decide to splice that in automagically.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@23Skidoo actually this makes me think of something... I think we should encode the spec-version somehow... e.g.
and we might want to tolerate not having to specify
default-language
w/ scripts, asdefault-{extensions,language}
makes less sense imho for scripts, as we have actual language pragmas (I've intentionally added one in the example above), and you certainly wouldn't want to replicate those...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about multi-file scripts? Easier to set
default-language
in one place than use a pragma in each file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@23Skidoo we can still support
default-language
; I just think we shouldn't force people to use it by emitting nasty warnings like we do for.cabal
files...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It skips that check on purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't we then need to parse
LANGUAGE
pragmas to make sure that they are actually specified whendefault-language
is absent?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@23Skidoo depends on the semantics you want to have for scripts...
However, I suggest we postpone this design/bikeshedding issue to a followup-task in order not to hold up merging this PR; I think all @typedrat needs to do is tweaks the docs and we're ready to go?