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 executable fall-through #1434

Merged
merged 1 commit into from
Nov 28, 2015
Merged

Add executable fall-through #1434

merged 1 commit into from
Nov 28, 2015

Conversation

yamadapc
Copy link
Contributor

Uses System.Directory.findExecutable. Adds a mOnInvalidArgs callback to the
complicatedOptions function on Options.Applicative.Complicated the rest of
the logic is centralized on Main.

I didn't use System.Process.Read.findExecutable because I'd then need
getMinimalEnvOverride, which would require GlobalOpts I think. I'm not sure,
but I don't understand what'd give at the moment.

Will rebase after discussion.

This closes #1433.

@yamadapc
Copy link
Contributor Author

Updated to conform to 2 spaces indentation and not run stylish-haskell on the files.

mExternalExec <- Directory.findExecutable ("stack-" ++ head as)
case mExternalExec of
Just ex -> do
ph <- spawnProcess ex (tail as)
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better if this replaces the current process instead of spawning a sub-process and just waiting for it to finish. Stack.Exec.exec will do that, but it's another function that needs an EnvOverride (this time via a Config). It's possible to create an EnvOverride using System.Process.Read.mkEnvOverride, and exec could be modified to take an EnvOverride as an argument instead of needing a Config.

@yamadapc
Copy link
Contributor Author

It seems like I'd still need a config to know the platform... I made some changes, but couldn't get this to work.

@borsboom
Copy link
Contributor

borsboom commented Nov 27, 2015 via email

@yamadapc
Copy link
Contributor Author

Cool, thanks for the tip; I should have asked sooner. Updated and rebased against origin/master. I made it so that the callback I added to Complicated.hs was run on every parser failure; not just arguments. This seemed better.

Not sure if I made the exec modification you mentioned?

@borsboom
Copy link
Contributor

Thanks, this is looking just about ready for merge. I tested it and everything seems to be in order. Please add an entry to the changelog, and maybe squash it into one commit.

@yamadapc
Copy link
Contributor Author

Okie, coolness! Squashed, changelog entry added and rebased against master.

This closes #1433. When an invalid `stack` command is issued, `stack`
will look in the `PATH` for a matching binary. So given there's an
executable `stack-something` in the `PATH`, issuing `stack something`
will execute it, rather than failing.

It uses `System.Directory.findExecutable` to find executables and `exec`
from `System.Process.Read` to execute the process.

Adds a mOnFailure callback to be called on parser failures to the
`Options.Complicated` parsing function.
borsboom added a commit that referenced this pull request Nov 28, 2015
…cutable-fallthrough

Add executable fall-through
@borsboom borsboom merged commit d6dae2a into commercialhaskell:master Nov 28, 2015
@yamadapc yamadapc deleted the enhancement/1433-git-style-executable-fallthrough branch November 28, 2015 17:58
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.

Plugin support with git-style "fall-through" of the executable call
2 participants