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

Export State(..) from Shelly #139

Open
samtay opened this issue Jan 11, 2017 · 2 comments
Open

Export State(..) from Shelly #139

samtay opened this issue Jan 11, 2017 · 2 comments

Comments

@samtay
Copy link

samtay commented Jan 11, 2017

Hi. I'm trying to write some simpler wrappers around native Shelly behavior, namely to have errExit True functionality, but without printing stack traces. It's a pretty simple wrap around runing commands, but it requires me to check the current state, something like:

-- | A version of Shelly's 'run' that avoids printing out a stack trace on error
run' :: FilePath -> [T.Text] -> Sh T.Text
run' fp args = do
  e    <- sErrExit <$> get
  stdo <- errExit False $ run fp args
  ex   <- lastExitCode
  if e && ex > 0
    then lastStdErr >>= errorExit'
    else return stdo

-- | A version of Shelly's 'errorExit' without debug information
errorExit' :: T.Text -> Sh a
errorExit' err = echo_err err >> quietExit 1

The problem is, State(..) is not exported from any exposed modules, so we have no way to deconstruct the a value of type State. Or more simply, in this example, I don't have access to sErrExit.

I see that you exported both get and set but these are useless without being able to access values in the return value of get. What are your thoughts? Is there a reason these are not exported?

@gregwebs
Copy link
Owner

I am quite open to exporting everything under an Internal module. State has always been treated as something that is not an interface, the interface approach would probably be to create a specific getter or settter.

@e4z9
Copy link

e4z9 commented Mar 8, 2020

I just wondered about the same, since I wanted my custom command to take the sFollowSymlink property into account. Saw that get is exported, and wondered what to do with it.

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

No branches or pull requests

3 participants