-
Notifications
You must be signed in to change notification settings - Fork 88
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
Customize the command printing function #228
Customize the command printing function #228
Conversation
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.
Please add test and investigate backwards compatibility, so a decision can be made whether this PR should be merged.
src/Shelly.hs
Outdated
@@ -1284,7 +1290,7 @@ runHandles exe args reusedHandles withHandles = do | |||
state <- get | |||
|
|||
let cmdString = show_command exe args | |||
when (sPrintCommands state) $ echo cmdString | |||
when (sPrintCommands state) $ liftIO $ sPrintCommandsFn state cmdString |
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.
Switching from echo
to sPrintCommandsFn
with standard semantics TIO.hPutStrLn
does not seem to preserve the current behavior, see the current definition of echo
:
Line 304 in 25a7884
echo msg = traceEcho msg >> liftIO (TIO.putStrLn msg >> hFlush stdout) |
Added a test, and I'm pretty sure it's backwards compatible because previously it was -- | Write a string to 'stdout', followed by a newline.
putStrLn :: Text -> IO ()
putStrLn = hPutStrLn stdout https://github.com/haskell/text/blob/1.2.4.1/src/Data/Text/IO.hs#L314-L316 |
9c0cf90
to
aabb60b
Compare
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.
Thanks for the test!
Also, now the semantics of echo
is preserved.
AFAICS, State
is an internal data structure not part of the API, so the API is only extended by a new function, not changed, so this could be released as a minor version (1.12.1). Is that right?
Could you formulate a sentence for the changelog?
Added a changelog entry. This adds an option to the API, so users don't have to change their code when they upgrade. |
So after merging your other PR (#229), there are conflicts... |
I'm on it |
daa2d1d
to
a7f36a5
Compare
Fixed conflicts |
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.
Thanks for the update!
Sorry, I have to request further changes. I remembered that there is also the API Shelly.Lifted
which should evolve in sync with Shelly
. Could you please extend this API by the new functionality? (That would be echoWith
and print_commands_with
, I think.)
0a0b789
to
b569b50
Compare
Updated |
Useful for adding color or a prefix like `"Running command: " <> cmd <> " ..."`. New in API: `echoWith`, `print_commands_with`
b569b50
to
db62da9
Compare
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.
Thanks!
I squashed the commits and bumped the version.
Candidate at: https://hackage.haskell.org/package/shelly-1.12.1/candidate/changelog
Useful for adding color or a prefix like
"Running command: " <> cmd <> " ..."
.