Skip to content

Conversation

@ChrisPenner
Copy link
Contributor

@ChrisPenner ChrisPenner commented Sep 22, 2021

Hello! Loving the tool so far, looking into a few tweaks to help make things a bit more scriptable; I'll try to break them up into manageable chunks :)

This first one is very simple and causes hdc to respect the "EOF" input, which, in almost all CLIs (including ghci). Many folks will have Ctrl-D muscle-memory to exit things, and now it'll work :)

It also allows you to script hdc much more easily from the CLI using stdin, since you can do things like pbpaste | hdc and it will run a query and quit. Currently it gets stuck in an infinite loop.

Right cmd -> evaluateCmd cmd `catchError` showFailure
where
showFailure e = liftIO $ putStrLn $ "Failed: "<> e
showFailure e = liftIO $ hPutStrLn stderr $ "Failed: "<> e
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also swapped some of the status and error messaging to use stderr so that stdout is more easily parseable by scripts and such. It should look exactly the same in regular terminal usage.

@lazamar
Copy link
Owner

lazamar commented Sep 23, 2021

This is excellent, thank you for that!

@lazamar lazamar merged commit c683f36 into lazamar:main Sep 23, 2021
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.

2 participants