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

Put user-facing output under control of 'usethis.quiet' option #424

Merged
merged 9 commits into from Aug 7, 2018

Conversation

Projects
None yet
2 participants
@jennybc
Member

jennybc commented Aug 3, 2018

Fixes #416 Need way to turn off messaging globally for usethis functions

Well, this was pretty satisfying!

I'm asking for review just to make sure I implemented as discussed and to see if there's anything else I can do along these lines to make life easier for someone using usethis in another package.

I'm also continuing to record implicit design principles explicitly in principles.md.

All of usethis's user-facing output goes through the cat_line() helper. I've put it under the control of a undocumented option "usethis.quiet".

So to use usethis functions quietly in a function do:

withr::local_options(list(usethis.quiet = TRUE))

cc @jimhester @isteves

@jennybc jennybc requested review from hadley and jimhester Aug 3, 2018

jennybc added some commits Aug 4, 2018

You might also notice that usethis communicates with the user via `cat()` instead of `message()`. Why?
* Pragmatic explanation: default styling of `message()` (at least in RStudio) is red, which suggests that something is wrong. We prefer default styling to be more neutral and less alarmist.
* Principled explanation: if one diverts where various streams go, `cat()` follows printed output, whereas `message()` goes to standard error.

This comment has been minimized.

@jimhester

jimhester Aug 6, 2018

Member

FWIW I don't agree with this principal, I think these status messages should be using message() (and stderr) and assuming RStudio / the Windows console did not re-color them I would push harder to make them use message().

If usethis was a normal unix program I would expect these user facing messages to be on stderr as they would be with message().

@jimhester

jimhester Aug 6, 2018

Member

FWIW I don't agree with this principal, I think these status messages should be using message() (and stderr) and assuming RStudio / the Windows console did not re-color them I would push harder to make them use message().

If usethis was a normal unix program I would expect these user facing messages to be on stderr as they would be with message().

This comment has been minimized.

@jennybc

jennybc Aug 6, 2018

Member

Yeah, you are not wrong. I just wrote this down because Irene had asked (she's using usethis in the package for Tidies of March) and I decide to record the rationale, such as it is. This would not be hard to change, since everything is so centralized.

@jennybc

jennybc Aug 6, 2018

Member

Yeah, you are not wrong. I just wrote this down because Irene had asked (she's using usethis in the package for Tidies of March) and I decide to record the rationale, such as it is. This would not be hard to change, since everything is so centralized.

Show outdated Hide outdated R/style.R

@jennybc jennybc merged commit b0df5f1 into master Aug 7, 2018

6 checks passed

codecov/patch 100% of diff hit (target 61.95%)
Details
codecov/project 61.98% (+0.02%) compared to 00ff3c4
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@jennybc jennybc deleted the usethis-quiet branch Aug 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment