You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
command plugins: Add a 'progress' diagnostic message at default verbosity (#7256)
This change adds a 'progress' message to the diagnostics which a plugin
can send back to SwiftPM. This message is printed to standard error at
the default verbosity level.
### Motivation:
Currently, a plugin can write output to standard output or send
diagnostics which SwiftPM writes to standard error. If the plugin spawns
long-running operations we might want to print progress messages to let
the user know that it is still running. The existing options all have
compromises:
* Anything the plugin prints to its standard output or standard error is
echoed to SwiftPM's standard output, but we may want to keep progress
information separate from other plugin outputs - the plugin might be
called as part of a shell pipeline where a downstream process will
consume its output, for example.
* The existing diagnostic messages - remark (info), warning and error -
are all suppressed at the default verbosity level.
* Increasing the level with `-v` causes SwiftPM to print lots of extra
logging information from the build, which swamps the plugin info
messages.
This commit adds a 'progress' message which SwiftPM will print to
standard error at the default verbosity level, allowing progress to be
shown without polluting standard output or pulling in additional build
logging which might not be relevant to the user.
### Modifications:
* `Diagnostics.progress` takes a message as a string and passes it to
SwiftPM, which prints it to standard error.
From the plugin programmer's point of view `Diagnostics.progress` is
logically a diagnostics message, however it is a new type in the SwiftPM
<-> plugin protocol because extending the existing diagnostics enum
would require extensive changes to add a the new message and in many
existing cases it would not be relevant.
### Result:
A plugin can show the user that it is making progress by printing
messages which SwiftPM will echoed to stderr at the default verbosity
level.
Example output (`diagnostics-stub` is the name of the plugin in
`Package.swift`):
```
% swift-package print-diagnostics progress
[diagnostics-stub] command plugin: Diagnostics.progress
```
0 commit comments