Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions R/signal.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,28 @@ signal_stage <- function(stage, what, with = NULL, env = caller_env()) {
what <- spec(what, env = env)

if (is_null(what$arg)) {
msg <- sprintf("%s() is %s", what$fn, stage)
message <- sprintf("%s() is %s", what$fn, stage)
} else {
msg <- sprintf("%s(%s) is %s", what$fn, what$arg, stage)
message <- sprintf("%s(%s) is %s", what$fn, what$arg, stage)
}

if (!is_null(with)) {
with <- spec(with, NULL, "signal_stage")
msg <- paste0(msg, "\n", lifecycle_message_with(with, what))
message <- paste0(message, "\n", lifecycle_message_with(with, what))
}

signal(
msg,
"lifecycle_stage",
# Much faster than calling `rlang::signal()` directly.
# `message` is already formatted so we don't need to worry about cli.
cnd_signal(cnd(
Copy link
Member

Choose a reason for hiding this comment

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

Can you make the condition object directly with structure()? (like simpleCondition())

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm, and use signalCondition()?

Copy link
Member Author

Choose a reason for hiding this comment

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

See #195 for the fully lazy way

class = "lifecycle_stage",
message = message,
stage = stage,
package = what$pkg,
function_nm = what$fn,
argument = what$arg,
reason = what$reason
)
reason = what$reason,
use_cli_format = FALSE
))
}

#' Deprecated functions for signalling experimental and lifecycle stages
Expand Down